aboutsummaryrefslogtreecommitdiff
path: root/src/server.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-05-17 05:56:26 +0000
committerMike Buland <eichlan@xagasoft.com>2007-05-17 05:56:26 +0000
commite0e7932a122614a0ff566fbfd8de5776de8b9f6d (patch)
treeae87ab46b677bfd05f340051a56f1edbc94862a9 /src/server.h
parentdda94f3b53e02e117e6eb5758afa1410e1664c9f (diff)
downloadlibbu++-e0e7932a122614a0ff566fbfd8de5776de8b9f6d.tar.gz
libbu++-e0e7932a122614a0ff566fbfd8de5776de8b9f6d.tar.bz2
libbu++-e0e7932a122614a0ff566fbfd8de5776de8b9f6d.tar.xz
libbu++-e0e7932a122614a0ff566fbfd8de5776de8b9f6d.zip
Lots of cool new stuff, the Server class actually works for everything except
actually interacting with clients, and the Client class is almost there, except that it doesn't really do anything yet.
Diffstat (limited to 'src/server.h')
-rw-r--r--src/server.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/server.h b/src/server.h
new file mode 100644
index 0000000..9f4f459
--- /dev/null
+++ b/src/server.h
@@ -0,0 +1,49 @@
1#ifndef SERVER_H
2#define SERVER_H
3
4#include <stdint.h>
5#include "bu/serversocket.h"
6#include "bu/list.h"
7#include "bu/client.h"
8
9namespace Bu
10{
11 /**
12 * Core of a network server. This class is distinct from a ServerSocket in
13 * that a ServerSocket is one listening socket, nothing more. Socket will
14 * manage a pool of both ServerSockets and connected Sockets along with
15 * their protocols and buffers.
16 *
17 * To start serving on a new port, use the addPort functions. Each call to
18 * addPort creates a new ServerSocket, starts it listening, and adds it to
19 * the server pool.
20 *
21 * All of the real work is done by scan, which will wait for up
22 * to the timeout set by setTimeout before returning if there is no data
23 * pending. scan should probably be called in some sort of tight
24 * loop, possibly in it's own thread, or in the main control loop.
25 */
26 class Server
27 {
28 public:
29 Server();
30 virtual ~Server();
31
32 void addPort( int nPort, int nPoolSize=40 );
33 void addPort( const FString &sAddr, int nPort, int nPoolSize=40 );
34
35 void scan();
36 void setTimeout( int nTimeoutSec, int nTimeoutUSec=0 );
37
38 void addClient( int nSocket );
39
40 private:
41 int nTimeoutSec;
42 int nTimeoutUSec;
43 fd_set fdActive;
44 Hash<int,ServerSocket *> hServers;
45 Hash<int,Client *> hClients;
46 };
47}
48
49#endif