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