Delta / NNN50_WIFI_API

Dependents:   NNN50_CE_Test_UDP NNN50_linux_firmware NNN50_SoftAP_HelloWorld NNN50_BLEWIFISensor ... more

Committer:
tsungta
Date:
Fri Jul 28 12:24:14 2017 +0000
Revision:
30:d3fe91d19774
Parent:
22:5b38592bc0e6
51:5165828

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tsungta 22:5b38592bc0e6 1 /* Copyright (C) 2012 mbed.org, MIT License
tsungta 22:5b38592bc0e6 2 *
tsungta 22:5b38592bc0e6 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
tsungta 22:5b38592bc0e6 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
tsungta 22:5b38592bc0e6 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
tsungta 22:5b38592bc0e6 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
tsungta 22:5b38592bc0e6 7 * furnished to do so, subject to the following conditions:
tsungta 22:5b38592bc0e6 8 *
tsungta 22:5b38592bc0e6 9 * The above copyright notice and this permission notice shall be included in all copies or
tsungta 22:5b38592bc0e6 10 * substantial portions of the Software.
tsungta 22:5b38592bc0e6 11 *
tsungta 22:5b38592bc0e6 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
tsungta 22:5b38592bc0e6 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
tsungta 22:5b38592bc0e6 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
tsungta 22:5b38592bc0e6 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tsungta 22:5b38592bc0e6 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tsungta 22:5b38592bc0e6 17 */
tsungta 22:5b38592bc0e6 18
tsungta 22:5b38592bc0e6 19 #ifndef TCPSOCKET_H
tsungta 22:5b38592bc0e6 20 #define TCPSOCKET_H
tsungta 22:5b38592bc0e6 21
tsungta 22:5b38592bc0e6 22 #include "Socket/Socket.h"
tsungta 22:5b38592bc0e6 23 #include "Socket/Endpoint.h"
tsungta 22:5b38592bc0e6 24
tsungta 22:5b38592bc0e6 25 #define TCP_BUFFER_SIZE SOCKET_BUFFER_MAX_LENGTH//Tsungta, set 0 if no buffer is required
tsungta 22:5b38592bc0e6 26
tsungta 22:5b38592bc0e6 27 /**
tsungta 22:5b38592bc0e6 28 TCP socket connection
tsungta 22:5b38592bc0e6 29 */
tsungta 22:5b38592bc0e6 30 class TCPSocketConnection : public Socket, public Endpoint {
tsungta 22:5b38592bc0e6 31 friend class TCPSocketServer;
tsungta 22:5b38592bc0e6 32
tsungta 22:5b38592bc0e6 33 public:
tsungta 22:5b38592bc0e6 34 /** TCP socket connection
tsungta 22:5b38592bc0e6 35 */
tsungta 22:5b38592bc0e6 36 TCPSocketConnection();
tsungta 22:5b38592bc0e6 37
tsungta 22:5b38592bc0e6 38 /** Connects this TCP socket to the server
tsungta 22:5b38592bc0e6 39 \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
tsungta 22:5b38592bc0e6 40 \param port The host's port to connect to.
tsungta 22:5b38592bc0e6 41 \return 0 on success, -1 on failure.
tsungta 22:5b38592bc0e6 42 */
tsungta 22:5b38592bc0e6 43 int connect(const char* host, const int port);
tsungta 22:5b38592bc0e6 44
tsungta 22:5b38592bc0e6 45 /** Check if the socket is connected
tsungta 22:5b38592bc0e6 46 \return true if connected, false otherwise.
tsungta 22:5b38592bc0e6 47 */
tsungta 22:5b38592bc0e6 48 bool is_connected(void);
tsungta 22:5b38592bc0e6 49
tsungta 22:5b38592bc0e6 50 /** Send data to the remote host.
tsungta 22:5b38592bc0e6 51 \param data The buffer to send to the host.
tsungta 22:5b38592bc0e6 52 \param length The length of the buffer to send.
tsungta 22:5b38592bc0e6 53 \return the number of written bytes on success (>=0) or -1 on failure
tsungta 22:5b38592bc0e6 54 */
tsungta 22:5b38592bc0e6 55 int send(char* data, int length);
tsungta 22:5b38592bc0e6 56
tsungta 22:5b38592bc0e6 57 /** Send all the data to the remote host.
tsungta 22:5b38592bc0e6 58 \param data The buffer to send to the host.
tsungta 22:5b38592bc0e6 59 \param length The length of the buffer to send.
tsungta 22:5b38592bc0e6 60 \return the number of written bytes on success (>=0) or -1 on failure
tsungta 22:5b38592bc0e6 61 */
tsungta 22:5b38592bc0e6 62 int send_all(char* data, int length);
tsungta 22:5b38592bc0e6 63
tsungta 22:5b38592bc0e6 64 /** Receive data from the remote host.
tsungta 22:5b38592bc0e6 65 \param data The buffer in which to store the data received from the host.
tsungta 22:5b38592bc0e6 66 \param length The maximum length of the buffer.
tsungta 22:5b38592bc0e6 67 \return the number of received bytes on success (>=0) or -1 on failure
tsungta 22:5b38592bc0e6 68 */
tsungta 22:5b38592bc0e6 69 int receive(char* data, int length);
tsungta 22:5b38592bc0e6 70
tsungta 22:5b38592bc0e6 71 /** Receive all the data from the remote host.
tsungta 22:5b38592bc0e6 72 \param data The buffer in which to store the data received from the host.
tsungta 22:5b38592bc0e6 73 \param length The maximum length of the buffer.
tsungta 22:5b38592bc0e6 74 \return the number of received bytes on success (>=0) or -1 on failure
tsungta 22:5b38592bc0e6 75 */
tsungta 22:5b38592bc0e6 76 int receive_all(char* data, int length);
tsungta 22:5b38592bc0e6 77
tsungta 22:5b38592bc0e6 78 private:
tsungta 22:5b38592bc0e6 79 bool _is_connected;
tsungta 22:5b38592bc0e6 80
tsungta 22:5b38592bc0e6 81 };
tsungta 22:5b38592bc0e6 82
tsungta 22:5b38592bc0e6 83 #endif
tsungta 22:5b38592bc0e6 84