summaryrefslogtreecommitdiff
path: root/src/test/srvstress
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-08-25 20:54:47 +0000
committerMike Buland <eichlan@xagasoft.com>2006-08-25 20:54:47 +0000
commit0a700ced28520be170c0965191f2450a2e4a82ac (patch)
tree6858e7178d9ddd30113824da4728729b06d018b5 /src/test/srvstress
parent0c2d075e795858779af102e932a881498e2268ae (diff)
downloadlibbu++-0a700ced28520be170c0965191f2450a2e4a82ac.tar.gz
libbu++-0a700ced28520be170c0965191f2450a2e4a82ac.tar.bz2
libbu++-0a700ced28520be170c0965191f2450a2e4a82ac.tar.xz
libbu++-0a700ced28520be170c0965191f2450a2e4a82ac.zip
Added tests and exception codes, so you're program can tell just how bad things
really are.
Diffstat (limited to '')
-rw-r--r--src/test/srvstress/main.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/test/srvstress/main.cpp b/src/test/srvstress/main.cpp
new file mode 100644
index 0000000..c7795e4
--- /dev/null
+++ b/src/test/srvstress/main.cpp
@@ -0,0 +1,86 @@
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
18 return true;
19 }
20
21 bool onNewConnection()
22 {
23 return true;
24 }
25};
26
27class StressMonitor : public ConnectionMonitor, public ProgramLink
28{
29public:
30 bool init()
31 {
32 return true;
33 }
34
35 bool deInit()
36 {
37 return true;
38 }
39
40 bool timeSlice()
41 {
42 }
43
44 bool onNewConnection( Connection *pCon, int nPort )
45 {
46 StressProtocol *sp = new StressProtocol();
47 pCon->setProtocol( sp );
48
49 printf(" sys: New connection: socket(%d), port(%d)\n",
50 pCon->getSocket(), nPort );
51
52 return true;
53 }
54
55 bool onClosedConnection( Connection *pCon )
56 {
57 printf(" sys: Closed connection: socket(%d)\n",
58 pCon->getSocket() );
59
60 return true;
61 }
62
63 LinkMessage *processIRM( LinkMessage *pMsg )
64 {
65 return NULL;
66 }
67};
68
69int main()
70{
71 printf("Starting server...\n");
72
73 ConnectionManager srv;
74 StressMonitor telnet;
75
76 srv.setConnectionMonitor( &telnet );
77
78 srv.startServer( 4001 );
79
80 for(;;)
81 {
82 srv.scanConnections( 5000, false );
83 }
84
85 return 0;
86}