reverted HTTPCLient debug back to defaulted off
Fork of MTS-Socket by
TCPSocketConnection.h@2:ebc6129de4e8, 2014-05-20 (annotated)
- Committer:
- Mike Fiore
- Date:
- Tue May 20 16:12:17 2014 -0500
- Revision:
- 2:ebc6129de4e8
- Parent:
- 1:096f484f3ae6
include mbed.h in cpp files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:096f484f3ae6 | 1 | #ifndef TCPSOCKETCONNECTION_H |
Mike Fiore |
1:096f484f3ae6 | 2 | #define TCPSOCKETCONNECTION_H |
Mike Fiore |
1:096f484f3ae6 | 3 | |
Mike Fiore |
1:096f484f3ae6 | 4 | #include "Socket.h" |
Mike Fiore |
1:096f484f3ae6 | 5 | #include "Endpoint.h" |
Mike Fiore |
1:096f484f3ae6 | 6 | |
Mike Fiore |
1:096f484f3ae6 | 7 | /** |
Mike Fiore |
1:096f484f3ae6 | 8 | TCP socket connection |
Mike Fiore |
1:096f484f3ae6 | 9 | */ |
Mike Fiore |
1:096f484f3ae6 | 10 | class TCPSocketConnection: public Socket, public Endpoint { |
Mike Fiore |
1:096f484f3ae6 | 11 | |
Mike Fiore |
1:096f484f3ae6 | 12 | public: |
Mike Fiore |
1:096f484f3ae6 | 13 | /** TCP socket connection |
Mike Fiore |
1:096f484f3ae6 | 14 | */ |
Mike Fiore |
1:096f484f3ae6 | 15 | TCPSocketConnection(); |
Mike Fiore |
1:096f484f3ae6 | 16 | |
Mike Fiore |
1:096f484f3ae6 | 17 | /** Connects this TCP socket to the server |
Mike Fiore |
1:096f484f3ae6 | 18 | \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS. |
Mike Fiore |
1:096f484f3ae6 | 19 | \param port The host's port to connect to. |
Mike Fiore |
1:096f484f3ae6 | 20 | \return 0 on success, -1 on failure. |
Mike Fiore |
1:096f484f3ae6 | 21 | */ |
Mike Fiore |
1:096f484f3ae6 | 22 | int connect(const char* host, const int port); |
Mike Fiore |
1:096f484f3ae6 | 23 | |
Mike Fiore |
1:096f484f3ae6 | 24 | /** Check if the socket is connected |
Mike Fiore |
1:096f484f3ae6 | 25 | \return true if connected, false otherwise. |
Mike Fiore |
1:096f484f3ae6 | 26 | */ |
Mike Fiore |
1:096f484f3ae6 | 27 | bool is_connected(void); |
Mike Fiore |
1:096f484f3ae6 | 28 | |
Mike Fiore |
1:096f484f3ae6 | 29 | /** Send data to the remote host. |
Mike Fiore |
1:096f484f3ae6 | 30 | \param data The buffer to send to the host. |
Mike Fiore |
1:096f484f3ae6 | 31 | \param length The length of the buffer to send. |
Mike Fiore |
1:096f484f3ae6 | 32 | \return the number of written bytes on success (>=0) or -1 on failure |
Mike Fiore |
1:096f484f3ae6 | 33 | */ |
Mike Fiore |
1:096f484f3ae6 | 34 | int send(char* data, int length); |
Mike Fiore |
1:096f484f3ae6 | 35 | |
Mike Fiore |
1:096f484f3ae6 | 36 | /** Send all the data to the remote host. |
Mike Fiore |
1:096f484f3ae6 | 37 | \param data The buffer to send to the host. |
Mike Fiore |
1:096f484f3ae6 | 38 | \param length The length of the buffer to send. |
Mike Fiore |
1:096f484f3ae6 | 39 | \return the number of written bytes on success (>=0) or -1 on failure |
Mike Fiore |
1:096f484f3ae6 | 40 | */ |
Mike Fiore |
1:096f484f3ae6 | 41 | int send_all(char* data, int length); |
Mike Fiore |
1:096f484f3ae6 | 42 | |
Mike Fiore |
1:096f484f3ae6 | 43 | /** Receive data from the remote host. |
Mike Fiore |
1:096f484f3ae6 | 44 | \param data The buffer in which to store the data received from the host. |
Mike Fiore |
1:096f484f3ae6 | 45 | \param length The maximum length of the buffer. |
Mike Fiore |
1:096f484f3ae6 | 46 | \return the number of received bytes on success (>=0) or -1 on failure |
Mike Fiore |
1:096f484f3ae6 | 47 | */ |
Mike Fiore |
1:096f484f3ae6 | 48 | int receive(char* data, int length); |
Mike Fiore |
1:096f484f3ae6 | 49 | |
Mike Fiore |
1:096f484f3ae6 | 50 | /** Receive all the data from the remote host. |
Mike Fiore |
1:096f484f3ae6 | 51 | \param data The buffer in which to store the data received from the host. |
Mike Fiore |
1:096f484f3ae6 | 52 | \param length The maximum length of the buffer. |
Mike Fiore |
1:096f484f3ae6 | 53 | \return the number of received bytes on success (>=0) or -1 on failure |
Mike Fiore |
1:096f484f3ae6 | 54 | */ |
Mike Fiore |
1:096f484f3ae6 | 55 | int receive_all(char* data, int length); |
Mike Fiore |
1:096f484f3ae6 | 56 | }; |
Mike Fiore |
1:096f484f3ae6 | 57 | |
Mike Fiore |
1:096f484f3ae6 | 58 | #endif |