Integrating the ublox LISA C200 modem
Fork of SprintUSBModemHTTPClientTest by
SprintUSBModem/Socket/TCPSocketConnection.h@5:3f93dd1d4cb3, 2013-09-26 (annotated)
- Committer:
- sam_grove
- Date:
- Thu Sep 26 00:44:20 2013 -0500
- Revision:
- 5:3f93dd1d4cb3
Exported program and replaced contents of the repo with the source
to build and debug using keil mdk. Libs NOT upto date are lwip, lwip-sys
and socket. these have newer versions under mbed_official but were starting
from a know working point
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 5:3f93dd1d4cb3 | 1 | /* Copyright (C) 2012 mbed.org, MIT License |
sam_grove | 5:3f93dd1d4cb3 | 2 | * |
sam_grove | 5:3f93dd1d4cb3 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
sam_grove | 5:3f93dd1d4cb3 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
sam_grove | 5:3f93dd1d4cb3 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
sam_grove | 5:3f93dd1d4cb3 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
sam_grove | 5:3f93dd1d4cb3 | 7 | * furnished to do so, subject to the following conditions: |
sam_grove | 5:3f93dd1d4cb3 | 8 | * |
sam_grove | 5:3f93dd1d4cb3 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
sam_grove | 5:3f93dd1d4cb3 | 10 | * substantial portions of the Software. |
sam_grove | 5:3f93dd1d4cb3 | 11 | * |
sam_grove | 5:3f93dd1d4cb3 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
sam_grove | 5:3f93dd1d4cb3 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
sam_grove | 5:3f93dd1d4cb3 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
sam_grove | 5:3f93dd1d4cb3 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
sam_grove | 5:3f93dd1d4cb3 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
sam_grove | 5:3f93dd1d4cb3 | 17 | */ |
sam_grove | 5:3f93dd1d4cb3 | 18 | |
sam_grove | 5:3f93dd1d4cb3 | 19 | #ifndef TCPSOCKET_H |
sam_grove | 5:3f93dd1d4cb3 | 20 | #define TCPSOCKET_H |
sam_grove | 5:3f93dd1d4cb3 | 21 | |
sam_grove | 5:3f93dd1d4cb3 | 22 | #include "Socket/Socket.h" |
sam_grove | 5:3f93dd1d4cb3 | 23 | #include "Socket/Endpoint.h" |
sam_grove | 5:3f93dd1d4cb3 | 24 | |
sam_grove | 5:3f93dd1d4cb3 | 25 | /** |
sam_grove | 5:3f93dd1d4cb3 | 26 | TCP socket connection |
sam_grove | 5:3f93dd1d4cb3 | 27 | */ |
sam_grove | 5:3f93dd1d4cb3 | 28 | class TCPSocketConnection : public Socket, public Endpoint { |
sam_grove | 5:3f93dd1d4cb3 | 29 | friend class TCPSocketServer; |
sam_grove | 5:3f93dd1d4cb3 | 30 | |
sam_grove | 5:3f93dd1d4cb3 | 31 | public: |
sam_grove | 5:3f93dd1d4cb3 | 32 | /** TCP socket connection |
sam_grove | 5:3f93dd1d4cb3 | 33 | */ |
sam_grove | 5:3f93dd1d4cb3 | 34 | TCPSocketConnection(); |
sam_grove | 5:3f93dd1d4cb3 | 35 | |
sam_grove | 5:3f93dd1d4cb3 | 36 | /** Connects this TCP socket to the server |
sam_grove | 5:3f93dd1d4cb3 | 37 | \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS. |
sam_grove | 5:3f93dd1d4cb3 | 38 | \param port The host's port to connect to. |
sam_grove | 5:3f93dd1d4cb3 | 39 | \return 0 on success, -1 on failure. |
sam_grove | 5:3f93dd1d4cb3 | 40 | */ |
sam_grove | 5:3f93dd1d4cb3 | 41 | int connect(const char* host, const int port); |
sam_grove | 5:3f93dd1d4cb3 | 42 | |
sam_grove | 5:3f93dd1d4cb3 | 43 | /** Check if the socket is connected |
sam_grove | 5:3f93dd1d4cb3 | 44 | \return true if connected, false otherwise. |
sam_grove | 5:3f93dd1d4cb3 | 45 | */ |
sam_grove | 5:3f93dd1d4cb3 | 46 | bool is_connected(void); |
sam_grove | 5:3f93dd1d4cb3 | 47 | |
sam_grove | 5:3f93dd1d4cb3 | 48 | /*! \brief Send data to the remote host. Applications are responsible for |
sam_grove | 5:3f93dd1d4cb3 | 49 | * checking that all data has been sent; if only some of the data was |
sam_grove | 5:3f93dd1d4cb3 | 50 | * transmitted, the application needs to attempt delivery of the |
sam_grove | 5:3f93dd1d4cb3 | 51 | * remaining data. |
sam_grove | 5:3f93dd1d4cb3 | 52 | * \param data The buffer to send to the host. |
sam_grove | 5:3f93dd1d4cb3 | 53 | * \param length The length of the buffer to send. |
sam_grove | 5:3f93dd1d4cb3 | 54 | * \return the number of written bytes on success (>=0) or -1 on failure |
sam_grove | 5:3f93dd1d4cb3 | 55 | */ |
sam_grove | 5:3f93dd1d4cb3 | 56 | int send(char* data, int length); |
sam_grove | 5:3f93dd1d4cb3 | 57 | |
sam_grove | 5:3f93dd1d4cb3 | 58 | /*! \brief Send all the data to the remote host. This method continues to send |
sam_grove | 5:3f93dd1d4cb3 | 59 | * data until either all data has been sent, or an error occurs, or a |
sam_grove | 5:3f93dd1d4cb3 | 60 | * timeout occurs. |
sam_grove | 5:3f93dd1d4cb3 | 61 | * \param data The buffer to send to the host. |
sam_grove | 5:3f93dd1d4cb3 | 62 | * \param length The length of the buffer to send. |
sam_grove | 5:3f93dd1d4cb3 | 63 | * \return the number of written bytes on success (>=0) or -1 on failure |
sam_grove | 5:3f93dd1d4cb3 | 64 | */ |
sam_grove | 5:3f93dd1d4cb3 | 65 | int send_all(char* data, int length); |
sam_grove | 5:3f93dd1d4cb3 | 66 | |
sam_grove | 5:3f93dd1d4cb3 | 67 | /*! \brief Receive data from the remote host. Return as soon as some data is |
sam_grove | 5:3f93dd1d4cb3 | 68 | * available. |
sam_grove | 5:3f93dd1d4cb3 | 69 | * \param data The buffer in which to store the data received from the host. |
sam_grove | 5:3f93dd1d4cb3 | 70 | * \param length The maximum length of the buffer. |
sam_grove | 5:3f93dd1d4cb3 | 71 | * \return the number of received bytes on success (>=0) or -1 on failure |
sam_grove | 5:3f93dd1d4cb3 | 72 | */ |
sam_grove | 5:3f93dd1d4cb3 | 73 | int receive(char* data, int length); |
sam_grove | 5:3f93dd1d4cb3 | 74 | |
sam_grove | 5:3f93dd1d4cb3 | 75 | /*! \brief Receive all the data from the remote host. This method continues to receive |
sam_grove | 5:3f93dd1d4cb3 | 76 | * data until either length bytes has been received, or an error occurs, or a |
sam_grove | 5:3f93dd1d4cb3 | 77 | * timeout occurs. |
sam_grove | 5:3f93dd1d4cb3 | 78 | * \param data The buffer in which to store the data received from the host. |
sam_grove | 5:3f93dd1d4cb3 | 79 | * \param length The maximum length of the buffer. |
sam_grove | 5:3f93dd1d4cb3 | 80 | * \return the number of received bytes on success (>=0) or -1 on failure |
sam_grove | 5:3f93dd1d4cb3 | 81 | */ |
sam_grove | 5:3f93dd1d4cb3 | 82 | int receive_all(char* data, int length); |
sam_grove | 5:3f93dd1d4cb3 | 83 | |
sam_grove | 5:3f93dd1d4cb3 | 84 | private: |
sam_grove | 5:3f93dd1d4cb3 | 85 | bool _is_connected; |
sam_grove | 5:3f93dd1d4cb3 | 86 | |
sam_grove | 5:3f93dd1d4cb3 | 87 | }; |
sam_grove | 5:3f93dd1d4cb3 | 88 | |
sam_grove | 5:3f93dd1d4cb3 | 89 | #endif |