aboutsummaryrefslogtreecommitdiff
path: root/src/serversocket.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/serversocket.h')
-rw-r--r--src/serversocket.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/serversocket.h b/src/serversocket.h
new file mode 100644
index 0000000..b4ee247
--- /dev/null
+++ b/src/serversocket.h
@@ -0,0 +1,39 @@
1#ifndef BU_SERVER_SOCKET_H
2#define BU_SERVER_SOCKET_H
3
4#include <stdint.h>
5#include "bu/fstring.h"
6
7namespace Bu
8{
9 /**
10 * A single tcp/ip server socket. When created the server socket will bind
11 * to the specified interface and port, and immediately begin listening for
12 * connections. When connections come in they are pooled by the networking
13 * drivers in the kernel until they are accepted, this means that failure
14 * to keep space in the connection pool will result in connection refusals.
15 *
16 * Although the accept function returns an integral file descriptor, it is
17 * designed to be used with the Socket class.
18 */
19 class ServerSocket
20 {
21 public:
22 ServerSocket( int nPort, int nPoolSize=40 );
23 ServerSocket( const FString &sAddr, int nPort, int nPoolSize=40 );
24 virtual ~ServerSocket();
25
26 int accept( int nTimeoutSec=0, int nTimeoutUSec=0 );
27 int getSocket();
28 int getPort();
29
30 private:
31 void startServer( struct sockaddr_in &name, int nPoolSize );
32
33 fd_set fdActive;
34 int nServer;
35 int nPort;
36 };
37}
38
39#endif