Implementation of the WifiPlusClick hardware module.
Dependents: WifiPlusKlickExample
TCPSocketServer.h
00001 /* Copyright (c) 2013 Henry Leinen (henry[dot]leinen [at] online [dot] de) 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 #ifndef __TCPSOCKETSERVER_H__ 00019 #define __TCPSOCKETSERVER_H__ 00020 00021 #include "Socket/Socket.h" 00022 #include "Socket/TCPSocketConnection.h" 00023 00024 /** Class TCPSocketServer inherits from class Socket. Implements the TCP server socket which is used to listen for a new incoming connection. 00025 * This implementation can have a backlog of up to 8 sockets. Please note that the number of listening sockets depends on how the WifiPlusClick 00026 * Module has been configured. 00027 */ 00028 class TCPSocketServer : public Socket 00029 { 00030 public: 00031 /** Public constructor to instantiate an object of TCPSocketServer. */ 00032 TCPSocketServer(); 00033 00034 /** Bind function to bind the TCPSocketServer to a specific local port as a precondition to listen to new connection requests. 00035 * @param port : local port to which the server socket shall be bound. 00036 * @returns : 0 if successfull, or -1 on failure. 00037 */ 00038 int bind(int port); 00039 00040 /** Listen function allows a bound socket to listen for incoming connections. The number of connectable socket objects can be specified. 00041 * @note: the number of sockets is a configurable resource on WifiPlusClick modules. Use the configuration function Wifi::SocketAllocate to 00042 * specify the number of sockets to allocate. 00043 * @param backlog : number of sockets which are connectable in the listen state. 00044 * @returns : the new backlog number, or -1 on failure 00045 */ 00046 int listen( int backlog = 1 ); 00047 00048 /** Accept function will be used on a bound and listening socket. Function will return if a socket connection has been made or a timeout occured. 00049 * @param connection : A reference to a TCCPSocketConnection object which will be a valid client socket if a connection has been made. 00050 * @returns : 0 if successfull, or -1 on failure. 00051 */ 00052 int accept(TCPSocketConnection& connection); 00053 }; 00054 00055 #endif // __TCPSOCKETSERVER_H__
Generated on Tue Jul 12 2022 23:18:35 by 1.7.2