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