SNICInterface for development
Fork of SNICInterface by
Socket/TCPSocketServer.h@29:6a0ba999597d, 2014-05-26 (annotated)
- Committer:
- kishino
- Date:
- Mon May 26 05:17:28 2014 +0000
- Revision:
- 29:6a0ba999597d
- Parent:
- 26:f2e1030964e4
- Child:
- 32:ae95309643aa
Changed the receive logic of UART.; Changed the use area of the global buffer.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kishino | 20:dd736d328de6 | 1 | /* Copyright (C) 2012 mbed.org, MIT License |
kishino | 20:dd736d328de6 | 2 | * |
kishino | 20:dd736d328de6 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
kishino | 20:dd736d328de6 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
kishino | 20:dd736d328de6 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
kishino | 20:dd736d328de6 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
kishino | 20:dd736d328de6 | 7 | * furnished to do so, subject to the following conditions: |
kishino | 20:dd736d328de6 | 8 | * |
kishino | 20:dd736d328de6 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
kishino | 20:dd736d328de6 | 10 | * substantial portions of the Software. |
kishino | 20:dd736d328de6 | 11 | * |
kishino | 20:dd736d328de6 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
kishino | 20:dd736d328de6 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
kishino | 20:dd736d328de6 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
kishino | 20:dd736d328de6 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
kishino | 20:dd736d328de6 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
kishino | 20:dd736d328de6 | 17 | */ |
kishino | 20:dd736d328de6 | 18 | /******************* Murata Manufacturing Co.,Ltd. 2014 ***************** |
kishino | 20:dd736d328de6 | 19 | * |
kishino | 20:dd736d328de6 | 20 | * Filename: TCPSocketServer.h |
kishino | 20:dd736d328de6 | 21 | * |
kishino | 20:dd736d328de6 | 22 | * Purpose: This module has define of TCP server. |
kishino | 20:dd736d328de6 | 23 | * |
kishino | 20:dd736d328de6 | 24 | * $Author: kishino $ |
kishino | 20:dd736d328de6 | 25 | * |
kishino | 20:dd736d328de6 | 26 | * $Date: 2014/03/26 $ |
kishino | 20:dd736d328de6 | 27 | * |
kishino | 20:dd736d328de6 | 28 | * $Revision: 0.0.0.1 $ |
kishino | 20:dd736d328de6 | 29 | * ***********************************************************************/ |
kishino | 20:dd736d328de6 | 30 | #ifndef TCPSOCKETSERVER_H |
kishino | 20:dd736d328de6 | 31 | #define TCPSOCKETSERVER_H |
kishino | 20:dd736d328de6 | 32 | |
kishino | 20:dd736d328de6 | 33 | #include "Socket.h" |
kishino | 20:dd736d328de6 | 34 | #include "TCPSocketConnection.h" |
kishino | 20:dd736d328de6 | 35 | |
kishino | 23:4ff2231ff9ba | 36 | /** |
kishino | 23:4ff2231ff9ba | 37 | Interface class for TCP server socket of using SNIC UART. |
kishino | 23:4ff2231ff9ba | 38 | |
kishino | 23:4ff2231ff9ba | 39 | */ |
kishino | 20:dd736d328de6 | 40 | class TCPSocketServer : public Socket { |
kishino | 20:dd736d328de6 | 41 | public: |
kishino | 20:dd736d328de6 | 42 | /** Instantiate a TCP Server. |
kishino | 20:dd736d328de6 | 43 | */ |
kishino | 20:dd736d328de6 | 44 | TCPSocketServer(); |
kishino | 26:f2e1030964e4 | 45 | virtual ~TCPSocketServer(); |
kishino | 20:dd736d328de6 | 46 | |
kishino | 20:dd736d328de6 | 47 | /** Bind a socket to a specific port. |
kishino | 20:dd736d328de6 | 48 | \param port The port to listen for incoming connections on. |
kishino | 20:dd736d328de6 | 49 | \return 0 on success, -1 on failure. |
kishino | 20:dd736d328de6 | 50 | */ |
kishino | 20:dd736d328de6 | 51 | int bind(int port); |
kishino | 20:dd736d328de6 | 52 | |
kishino | 20:dd736d328de6 | 53 | /** Start listening for incoming connections. |
kishino | 20:dd736d328de6 | 54 | \param backlog number of pending connections that can be queued up at any |
kishino | 20:dd736d328de6 | 55 | one time [Default: 1]. |
kishino | 20:dd736d328de6 | 56 | \return 0 on success, -1 on failure. |
kishino | 20:dd736d328de6 | 57 | */ |
kishino | 20:dd736d328de6 | 58 | int listen(int backlog=1); |
kishino | 20:dd736d328de6 | 59 | |
kishino | 20:dd736d328de6 | 60 | /** Accept a new connection. |
kishino | 20:dd736d328de6 | 61 | \param connection A TCPSocketConnection instance that will handle the incoming connection. |
kishino | 20:dd736d328de6 | 62 | \return 0 on success, -1 on failure. |
kishino | 20:dd736d328de6 | 63 | */ |
kishino | 20:dd736d328de6 | 64 | int accept(TCPSocketConnection& connection); |
kishino | 20:dd736d328de6 | 65 | }; |
kishino | 20:dd736d328de6 | 66 | |
kishino | 20:dd736d328de6 | 67 | #endif |