uses pushing box to write to google spreadsheets
Dependencies: GSM_PUSHING_BOX_STATE_MACHINE MBed_Adafruit-GPS-Library SDFileSystem mbed
Fork of DCS by
Socket/TCPSocketConnection.h@20:84661ac75715, 2015-10-21 (annotated)
- Committer:
- DeWayneDennis
- Date:
- Wed Oct 21 19:46:32 2015 +0000
- Revision:
- 20:84661ac75715
- Parent:
- 19:404594768414
a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DeWayneDennis | 19:404594768414 | 1 | /* |
DeWayneDennis | 19:404594768414 | 2 | TCPSocketConnection.h |
DeWayneDennis | 19:404594768414 | 3 | 2014 Copyright (c) Seeed Technology Inc. All right reserved. |
DeWayneDennis | 19:404594768414 | 4 | |
DeWayneDennis | 19:404594768414 | 5 | Author:lawliet zou(lawliet.zou@gmail.com) |
DeWayneDennis | 19:404594768414 | 6 | 2014-2-24 |
DeWayneDennis | 19:404594768414 | 7 | |
DeWayneDennis | 19:404594768414 | 8 | This library is free software; you can redistribute it and/or |
DeWayneDennis | 19:404594768414 | 9 | modify it under the terms of the GNU Lesser General Public |
DeWayneDennis | 19:404594768414 | 10 | License as published by the Free Software Foundation; either |
DeWayneDennis | 19:404594768414 | 11 | version 2.1 of the License, or (at your option) any later version. |
DeWayneDennis | 19:404594768414 | 12 | |
DeWayneDennis | 19:404594768414 | 13 | This library is distributed in the hope that it will be useful, |
DeWayneDennis | 19:404594768414 | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
DeWayneDennis | 19:404594768414 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
DeWayneDennis | 19:404594768414 | 16 | Lesser General Public License for more details. |
DeWayneDennis | 19:404594768414 | 17 | |
DeWayneDennis | 19:404594768414 | 18 | You should have received a copy of the GNU Lesser General Public |
DeWayneDennis | 19:404594768414 | 19 | License along with this library; if not, write to the Free Software |
DeWayneDennis | 19:404594768414 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
DeWayneDennis | 19:404594768414 | 21 | */ |
DeWayneDennis | 19:404594768414 | 22 | |
DeWayneDennis | 19:404594768414 | 23 | #ifndef TCPSOCKET_H |
DeWayneDennis | 19:404594768414 | 24 | #define TCPSOCKET_H |
DeWayneDennis | 19:404594768414 | 25 | |
DeWayneDennis | 19:404594768414 | 26 | #include "Socket.h" |
DeWayneDennis | 19:404594768414 | 27 | |
DeWayneDennis | 19:404594768414 | 28 | /** TCP socket connection |
DeWayneDennis | 19:404594768414 | 29 | */ |
DeWayneDennis | 19:404594768414 | 30 | class TCPSocketConnection: public Socket |
DeWayneDennis | 19:404594768414 | 31 | { |
DeWayneDennis | 19:404594768414 | 32 | friend class TCPSocketServer; |
DeWayneDennis | 19:404594768414 | 33 | |
DeWayneDennis | 19:404594768414 | 34 | public: |
DeWayneDennis | 19:404594768414 | 35 | /** TCP socket connection |
DeWayneDennis | 19:404594768414 | 36 | */ |
DeWayneDennis | 19:404594768414 | 37 | TCPSocketConnection(); |
DeWayneDennis | 19:404594768414 | 38 | |
DeWayneDennis | 19:404594768414 | 39 | /** Connects this TCP socket to the server |
DeWayneDennis | 19:404594768414 | 40 | \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS. |
DeWayneDennis | 19:404594768414 | 41 | \param port The host's port to connect to. |
DeWayneDennis | 19:404594768414 | 42 | \return 0 on success, -1 on failure. |
DeWayneDennis | 19:404594768414 | 43 | */ |
DeWayneDennis | 19:404594768414 | 44 | int connect(const char* host, const int port); |
DeWayneDennis | 19:404594768414 | 45 | |
DeWayneDennis | 19:404594768414 | 46 | /** Check if the socket is connected |
DeWayneDennis | 19:404594768414 | 47 | \return true if connected, false otherwise. |
DeWayneDennis | 19:404594768414 | 48 | */ |
DeWayneDennis | 19:404594768414 | 49 | bool is_connected(void); |
DeWayneDennis | 19:404594768414 | 50 | |
DeWayneDennis | 19:404594768414 | 51 | /** Send data to the remote host. |
DeWayneDennis | 19:404594768414 | 52 | \param data The buffer to send to the host. |
DeWayneDennis | 19:404594768414 | 53 | \param length The length of the buffer to send. |
DeWayneDennis | 19:404594768414 | 54 | \return the number of written bytes on success (>=0) or -1 on failure |
DeWayneDennis | 19:404594768414 | 55 | */ |
DeWayneDennis | 19:404594768414 | 56 | int send(char* data, int length); |
DeWayneDennis | 19:404594768414 | 57 | |
DeWayneDennis | 19:404594768414 | 58 | /** Send all the data to the remote host. |
DeWayneDennis | 19:404594768414 | 59 | \param data The buffer to send to the host. |
DeWayneDennis | 19:404594768414 | 60 | \param length The length of the buffer to send. |
DeWayneDennis | 19:404594768414 | 61 | \return the number of written bytes on success (>=0) or -1 on failure |
DeWayneDennis | 19:404594768414 | 62 | */ |
DeWayneDennis | 19:404594768414 | 63 | int send_all(char* data, int length); |
DeWayneDennis | 19:404594768414 | 64 | |
DeWayneDennis | 19:404594768414 | 65 | /** Receive data from the remote host. |
DeWayneDennis | 19:404594768414 | 66 | \param data The buffer in which to store the data received from the host. |
DeWayneDennis | 19:404594768414 | 67 | \param length The maximum length of the buffer. |
DeWayneDennis | 19:404594768414 | 68 | \return the number of received bytes on success (>=0) or -1 on failure |
DeWayneDennis | 19:404594768414 | 69 | */ |
DeWayneDennis | 19:404594768414 | 70 | int receive(char* data, int length); |
DeWayneDennis | 19:404594768414 | 71 | |
DeWayneDennis | 19:404594768414 | 72 | /** Receive all the data from the remote host. |
DeWayneDennis | 19:404594768414 | 73 | \param data The buffer in which to store the data received from the host. |
DeWayneDennis | 19:404594768414 | 74 | \param length The maximum length of the buffer. |
DeWayneDennis | 19:404594768414 | 75 | \return the number of received bytes on success (>=0) or -1 on failure |
DeWayneDennis | 19:404594768414 | 76 | */ |
DeWayneDennis | 19:404594768414 | 77 | int receive_all(char* data, int length); |
DeWayneDennis | 19:404594768414 | 78 | }; |
DeWayneDennis | 19:404594768414 | 79 | |
DeWayneDennis | 19:404594768414 | 80 | #endif |