NetworkSocketAPI

Dependencies:   DnsQuery

Dependents:   HelloWizFi250Interface

Fork of NetworkSocketAPI by NetworkSocketAPI

TCPSocket.cpp

Committer:
Christopher Haster
Date:
2016-02-18
Branch:
api-changes
Revision:
24:a5e959bdd2dd
Parent:
22:4fca633c0633
Child:
25:ed7b2a52e8ac

File content as of revision 24:a5e959bdd2dd:

/* TCPSocket
 * Copyright (c) 2015 ARM Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "TCPSocket.h"

TCPSocket::TCPSocket(NetworkInterface *iface, const char *ip, uint16_t port)
  : _iface(iface) {
    _socket = _iface->createSocket(SOCK_TCP);

    if (ip)   setIPAddress(ip);
    if (port) setPort(port);
}

TCPSocket::~TCPSocket() {
    _iface->destroySocket(_socket);
}

void TCPSocket::setURL(const char *url) {
    return _socket->setURL(url);
}

void TCPSocket::setIPAddress(const char *ip) {
    return _socket->setIPAddress(ip);
}

void TCPSocket::setPort(uint16_t port) {
    return _socket->setPort(port);
}

const char *TCPSocket::getIPAddress() {
    return _socket->getIPAddress();
}

uint16_t TCPSocket::getPort() {
    return _socket->getPort();
}

int32_t TCPSocket::open() {
    return _socket->open();
}

int32_t TCPSocket::close() {
    return _socket->close();
}

int32_t TCPSocket::send(const void *data, uint32_t len, uint32_t timeout_ms) {
    return _socket->send(data, len, timeout_ms);
}

int32_t TCPSocket::recv(void *data, uint32_t len, uint32_t timeout_ms) {
    return _socket->recv(data, len, timeout_ms);
}