Eric Wu / Mbed 2 deprecated WifiRobot

Dependencies:   mbed

Committer:
wueric
Date:
Tue Dec 09 05:06:37 2014 +0000
Revision:
0:2deb247ab4bd
sharing stuff;

Who changed what in which revision?

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