ST Americas mbed Team / Mbed 2 deprecated m2x-accel_ethernet_demo

Dependencies:   LM75B M2XStreamClient jsonlite mbed-rtos mbed

Fork of m2x-seeed_ethernet_demo by Sean Newton

Committer:
SeanNewton
Date:
Tue Sep 30 00:32:20 2014 +0000
Revision:
3:0fba8849a883
Initial Release

Who changed what in which revision?

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