Free (GPLv2) TCP/IP stack developed by TASS Belgium
Dependents: lpc1768-picotcp-demo ZeroMQ_PicoTCP_Publisher_demo TCPSocket_HelloWorld_PicoTCP Pico_TCP_UDP_Test ... more
TCPSocketConnection.h
00001 /* 00002 * 00003 * PicoTCP Socket interface for mbed. 00004 * Copyright (C) 2013 TASS Belgium NV 00005 * 00006 * Released under GPL v2 00007 * 00008 * Other licensing models might apply at the sole discretion of the copyright holders. 00009 * 00010 * 00011 * This software is based on the mbed.org EthernetInterface implementation: 00012 * Copyright (C) 2012 mbed.org, MIT License 00013 * 00014 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00015 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00016 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00017 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00018 * furnished to do so, subject to the following conditions: 00019 * 00020 * The above copyright notice and this permission notice shall be included in all copies or 00021 * substantial portions of the Software. 00022 * 00023 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00024 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00025 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00026 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00027 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00028 */ 00029 00030 #ifndef TCPSOCKET_H 00031 #define TCPSOCKET_H 00032 00033 #include "Socket/Socket.h" 00034 #include "Socket/Endpoint.h" 00035 00036 /** 00037 TCP socket connection 00038 */ 00039 class TCPSocketConnection : public Socket, public Endpoint { 00040 friend class TCPSocketServer; 00041 00042 public: 00043 /** TCP socket connection 00044 */ 00045 TCPSocketConnection(); 00046 00047 /** Connects this TCP socket to the server 00048 \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS. 00049 \param port The host's port to connect to. 00050 \return 0 on success, -1 on failure. 00051 */ 00052 int connect(const char* host, const int port); 00053 00054 /** Check if the socket is connected 00055 \return true if connected, false otherwise. 00056 */ 00057 bool is_connected(void); 00058 00059 /** Send data to the remote host. 00060 \param data The buffer to send to the host. 00061 \param length The length of the buffer to send. 00062 \return the number of written bytes on success (>=0) or -1 on failure 00063 */ 00064 int send(char* data, int length); 00065 00066 /** Send all the data to the remote host. 00067 \param data The buffer to send to the host. 00068 \param length The length of the buffer to send. 00069 \return the number of written bytes on success (>=0) or -1 on failure 00070 */ 00071 int send_all(char* data, int length); 00072 00073 /** Receive data from the remote host. 00074 \param data The buffer in which to store the data received from the host. 00075 \param length The maximum length of the buffer. 00076 \return the number of received bytes on success (>=0) or -1 on failure 00077 */ 00078 int receive(char* data, int length); 00079 00080 /** Receive all the data from the remote host. 00081 \param data The buffer in which to store the data received from the host. 00082 \param length The maximum length of the buffer. 00083 \return the number of received bytes on success (>=0) or -1 on failure 00084 */ 00085 int receive_all(char* data, int length); 00086 }; 00087 00088 #endif
Generated on Tue Jul 12 2022 15:59:22 by 1.7.2