aboutsummaryrefslogtreecommitdiff
path: root/src/tests/srvstress.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-10-11 15:54:09 +0000
committerMike Buland <eichlan@xagasoft.com>2006-10-11 15:54:09 +0000
commita77e41eee42b99282c05d268479ba5ebb11dc095 (patch)
treed211c2e3978ba6ed6c91b8b430a85d59d50079f9 /src/tests/srvstress.cpp
parent745875139b5ee46e469927d410364bfeeedb2995 (diff)
downloadlibbu++-a77e41eee42b99282c05d268479ba5ebb11dc095.tar.gz
libbu++-a77e41eee42b99282c05d268479ba5ebb11dc095.tar.bz2
libbu++-a77e41eee42b99282c05d268479ba5ebb11dc095.tar.xz
libbu++-a77e41eee42b99282c05d268479ba5ebb11dc095.zip
Rearranged the tests, now it's like the old style, which I like more for some
reason.
Diffstat (limited to 'src/tests/srvstress.cpp')
-rw-r--r--src/tests/srvstress.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/tests/srvstress.cpp b/src/tests/srvstress.cpp
new file mode 100644
index 0000000..7fe7657
--- /dev/null
+++ b/src/tests/srvstress.cpp
@@ -0,0 +1,90 @@
1#include "connectionmanager.h"
2#include "programlink.h"
3#include "linkedlist.h"
4#include "protocol.h"
5
6class StressProtocol : public Protocol
7{
8public:
9 bool onNewData()
10 {
11 switch( getConnection()->getInput()[0] )
12 {
13 case 'd':
14 throw "Hello";
15 break;
16
17 case 'w':
18 getConnection()->appendOutput("Hello");
19 break;
20 };
21
22 return true;
23 }
24
25 bool onNewConnection()
26 {
27 return true;
28 }
29};
30
31class StressMonitor : public ConnectionMonitor, public ProgramLink
32{
33public:
34 bool init()
35 {
36 return true;
37 }
38
39 bool deInit()
40 {
41 return true;
42 }
43
44 bool timeSlice()
45 {
46 }
47
48 bool onNewConnection( Connection *pCon, int nPort )
49 {
50 StressProtocol *sp = new StressProtocol();
51 pCon->setProtocol( sp );
52
53 printf(" sys: New connection: socket(%d), port(%d)\n",
54 pCon->getSocket(), nPort );
55
56 return true;
57 }
58
59 bool onClosedConnection( Connection *pCon )
60 {
61 printf(" sys: Closed connection: socket(%d)\n",
62 pCon->getSocket() );
63
64 return true;
65 }
66
67 LinkMessage *processIRM( LinkMessage *pMsg )
68 {
69 return NULL;
70 }
71};
72
73int main()
74{
75 printf("Starting server...\n");
76
77 ConnectionManager srv;
78 StressMonitor telnet;
79
80 srv.setConnectionMonitor( &telnet );
81
82 srv.startServer( 4001 );
83
84 for(;;)
85 {
86 srv.scanConnections( 5000, false );
87 }
88
89 return 0;
90}