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