aboutsummaryrefslogtreecommitdiff
path: root/src/tests/srvstress
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/srvstress')
-rw-r--r--src/tests/srvstress/main.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/tests/srvstress/main.cpp b/src/tests/srvstress/main.cpp
new file mode 100644
index 0000000..7fe7657
--- /dev/null
+++ b/src/tests/srvstress/main.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}