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