The code from https://github.com/vpcola/Nucleo

Committer:
sinrab
Date:
Wed Oct 08 11:00:24 2014 +0000
Revision:
0:5464d5e415e5
The code from https://github.com/vpcola/Nucleo

Who changed what in which revision?

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