fort Socket

Fork of Socket by mbed official

Committer:
emilmont
Date:
Wed Aug 01 13:02:32 2012 +0000
Revision:
11:3d83c348fb8b
Parent:
10:d24738f4ef99
Child:
16:2d471deff212
[Socket library] Remove redundant UDPPacket class. Use centralized socket destructor. Add is_connected check.

Who changed what in which revision?

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