xdw

Fork of WizFi310Interface_Legacynew by Akshay Tom

Committer:
kaizen
Date:
Wed Apr 19 00:46:44 2017 +0000
Revision:
0:774ff1e8b26b
First release WizFi310Interface for mbed OS2 ( Legacy version )

Who changed what in which revision?

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