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