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