update main WIZnetInterface library for supporting honeypot server
Fork of WIZnetInterface by
Update WIZnetInterface for supporting Honeypot server
Update sockets handling.
//add new type to enum status SOCK_TIMEOUT = 0x23,
Socket/TCPSocketServer.h@30:58f7cd21cf37, 2017-09-01 (annotated)
- Committer:
- proxytype
- Date:
- Fri Sep 01 23:36:01 2017 +0000
- Revision:
- 30:58f7cd21cf37
- Parent:
- 0:6f28332c466f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Soohwan Kim |
0:6f28332c466f | 1 | /* Copyright (C) 2012 mbed.org, MIT License |
Soohwan Kim |
0:6f28332c466f | 2 | * |
Soohwan Kim |
0:6f28332c466f | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
Soohwan Kim |
0:6f28332c466f | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
Soohwan Kim |
0:6f28332c466f | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
Soohwan Kim |
0:6f28332c466f | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
Soohwan Kim |
0:6f28332c466f | 7 | * furnished to do so, subject to the following conditions: |
Soohwan Kim |
0:6f28332c466f | 8 | * |
Soohwan Kim |
0:6f28332c466f | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
Soohwan Kim |
0:6f28332c466f | 10 | * substantial portions of the Software. |
Soohwan Kim |
0:6f28332c466f | 11 | * |
Soohwan Kim |
0:6f28332c466f | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
Soohwan Kim |
0:6f28332c466f | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
Soohwan Kim |
0:6f28332c466f | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
Soohwan Kim |
0:6f28332c466f | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Soohwan Kim |
0:6f28332c466f | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Soohwan Kim |
0:6f28332c466f | 17 | */ |
Soohwan Kim |
0:6f28332c466f | 18 | #ifndef TCPSOCKETSERVER_H |
Soohwan Kim |
0:6f28332c466f | 19 | #define TCPSOCKETSERVER_H |
Soohwan Kim |
0:6f28332c466f | 20 | |
Soohwan Kim |
0:6f28332c466f | 21 | #include "Socket.h" |
Soohwan Kim |
0:6f28332c466f | 22 | #include "TCPSocketConnection.h" |
Soohwan Kim |
0:6f28332c466f | 23 | |
Soohwan Kim |
0:6f28332c466f | 24 | /** TCP Server. |
Soohwan Kim |
0:6f28332c466f | 25 | */ |
Soohwan Kim |
0:6f28332c466f | 26 | class TCPSocketServer : public Socket |
Soohwan Kim |
0:6f28332c466f | 27 | { |
Soohwan Kim |
0:6f28332c466f | 28 | public: |
Soohwan Kim |
0:6f28332c466f | 29 | /** Instantiate a TCP Server. |
Soohwan Kim |
0:6f28332c466f | 30 | */ |
proxytype | 30:58f7cd21cf37 | 31 | |
Soohwan Kim |
0:6f28332c466f | 32 | TCPSocketServer(); |
Soohwan Kim |
0:6f28332c466f | 33 | |
Soohwan Kim |
0:6f28332c466f | 34 | /** Bind a socket to a specific port. |
Soohwan Kim |
0:6f28332c466f | 35 | \param port The port to listen for incoming connections on. |
Soohwan Kim |
0:6f28332c466f | 36 | \return 0 on success, -1 on failure. |
Soohwan Kim |
0:6f28332c466f | 37 | */ |
Soohwan Kim |
0:6f28332c466f | 38 | int bind(int port); |
Soohwan Kim |
0:6f28332c466f | 39 | |
Soohwan Kim |
0:6f28332c466f | 40 | /** Start listening for incoming connections. |
Soohwan Kim |
0:6f28332c466f | 41 | \param backlog number of pending connections that can be queued up at any |
Soohwan Kim |
0:6f28332c466f | 42 | one time [Default: 1]. |
Soohwan Kim |
0:6f28332c466f | 43 | \return 0 on success, -1 on failure. |
Soohwan Kim |
0:6f28332c466f | 44 | */ |
Soohwan Kim |
0:6f28332c466f | 45 | int listen(int backlog=1); |
Soohwan Kim |
0:6f28332c466f | 46 | |
Soohwan Kim |
0:6f28332c466f | 47 | /** Accept a new connection. |
Soohwan Kim |
0:6f28332c466f | 48 | \param connection A TCPSocketConnection instance that will handle the incoming connection. |
Soohwan Kim |
0:6f28332c466f | 49 | \return 0 on success, -1 on failure. |
Soohwan Kim |
0:6f28332c466f | 50 | */ |
Soohwan Kim |
0:6f28332c466f | 51 | int accept(TCPSocketConnection& connection); |
proxytype | 30:58f7cd21cf37 | 52 | int getPort(); |
Soohwan Kim |
0:6f28332c466f | 53 | |
Soohwan Kim |
0:6f28332c466f | 54 | private : |
Soohwan Kim |
0:6f28332c466f | 55 | int listen_port; |
Soohwan Kim |
0:6f28332c466f | 56 | }; |
Soohwan Kim |
0:6f28332c466f | 57 | |
Soohwan Kim |
0:6f28332c466f | 58 | #endif |
Soohwan Kim |
0:6f28332c466f | 59 |