Final Code 12/19/2015

Dependents:   DCS_FINAL_CODE

Committer:
DeWayneDennis
Date:
Sat Dec 19 21:57:34 2015 +0000
Revision:
0:b49935f48132
Final Code 12/19/2015

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DeWayneDennis 0:b49935f48132 1 /*
DeWayneDennis 0:b49935f48132 2 TCPSocketServer.h
DeWayneDennis 0:b49935f48132 3 2014 Copyright (c) Seeed Technology Inc. All right reserved.
DeWayneDennis 0:b49935f48132 4
DeWayneDennis 0:b49935f48132 5 Author:lawliet zou(lawliet.zou@gmail.com)
DeWayneDennis 0:b49935f48132 6 2014-2-24
DeWayneDennis 0:b49935f48132 7
DeWayneDennis 0:b49935f48132 8 This library is free software; you can redistribute it and/or
DeWayneDennis 0:b49935f48132 9 modify it under the terms of the GNU Lesser General Public
DeWayneDennis 0:b49935f48132 10 License as published by the Free Software Foundation; either
DeWayneDennis 0:b49935f48132 11 version 2.1 of the License, or (at your option) any later version.
DeWayneDennis 0:b49935f48132 12
DeWayneDennis 0:b49935f48132 13 This library is distributed in the hope that it will be useful,
DeWayneDennis 0:b49935f48132 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
DeWayneDennis 0:b49935f48132 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
DeWayneDennis 0:b49935f48132 16 Lesser General Public License for more details.
DeWayneDennis 0:b49935f48132 17
DeWayneDennis 0:b49935f48132 18 You should have received a copy of the GNU Lesser General Public
DeWayneDennis 0:b49935f48132 19 License along with this library; if not, write to the Free Software
DeWayneDennis 0:b49935f48132 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
DeWayneDennis 0:b49935f48132 21 */
DeWayneDennis 0:b49935f48132 22 #ifndef TCPSOCKETSERVER_H
DeWayneDennis 0:b49935f48132 23 #define TCPSOCKETSERVER_H
DeWayneDennis 0:b49935f48132 24
DeWayneDennis 0:b49935f48132 25 #include "Socket/Socket.h"
DeWayneDennis 0:b49935f48132 26 #include "TCPSocketConnection.h"
DeWayneDennis 0:b49935f48132 27
DeWayneDennis 0:b49935f48132 28 /** TCP Server.
DeWayneDennis 0:b49935f48132 29 */
DeWayneDennis 0:b49935f48132 30 class TCPSocketServer : public Socket
DeWayneDennis 0:b49935f48132 31 {
DeWayneDennis 0:b49935f48132 32 public:
DeWayneDennis 0:b49935f48132 33 /** Instantiate a TCP Server.
DeWayneDennis 0:b49935f48132 34 */
DeWayneDennis 0:b49935f48132 35 TCPSocketServer();
DeWayneDennis 0:b49935f48132 36
DeWayneDennis 0:b49935f48132 37 /** Bind a socket to a specific port.
DeWayneDennis 0:b49935f48132 38 \param port The port to listen for incoming connections on.
DeWayneDennis 0:b49935f48132 39 \return 0 on success, -1 on failure.
DeWayneDennis 0:b49935f48132 40 */
DeWayneDennis 0:b49935f48132 41 int bind(int port);
DeWayneDennis 0:b49935f48132 42
DeWayneDennis 0:b49935f48132 43 /** Start listening for incoming connections.
DeWayneDennis 0:b49935f48132 44 \param backlog number of pending connections that can be queued up at any
DeWayneDennis 0:b49935f48132 45 one time [Default: 1].
DeWayneDennis 0:b49935f48132 46 \return 0 on success, -1 on failure.
DeWayneDennis 0:b49935f48132 47 */
DeWayneDennis 0:b49935f48132 48 int listen(int backlog=1);
DeWayneDennis 0:b49935f48132 49
DeWayneDennis 0:b49935f48132 50 /** Accept a new connection.
DeWayneDennis 0:b49935f48132 51 \param connection A TCPSocketConnection instance that will handle the incoming connection.
DeWayneDennis 0:b49935f48132 52 \return 0 on success, -1 on failure.
DeWayneDennis 0:b49935f48132 53 */
DeWayneDennis 0:b49935f48132 54 int accept(TCPSocketConnection& connection);
DeWayneDennis 0:b49935f48132 55 };
DeWayneDennis 0:b49935f48132 56
DeWayneDennis 0:b49935f48132 57 #endif