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