aboutsummaryrefslogtreecommitdiff
path: root/src/tests/socketblock.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-07-03 00:50:59 +0000
committerMike Buland <eichlan@xagasoft.com>2007-07-03 00:50:59 +0000
commitf7f45e9630912cfca6b3a6b60577f02924c3dbc9 (patch)
treebac0b1088b3bcd4407417dbf20a69812c1b8f2e5 /src/tests/socketblock.cpp
parent395a9f1b8ce44d55dbe4496ce34e1ec6a6e2a3ba (diff)
downloadlibbu++-f7f45e9630912cfca6b3a6b60577f02924c3dbc9.tar.gz
libbu++-f7f45e9630912cfca6b3a6b60577f02924c3dbc9.tar.bz2
libbu++-f7f45e9630912cfca6b3a6b60577f02924c3dbc9.tar.xz
libbu++-f7f45e9630912cfca6b3a6b60577f02924c3dbc9.zip
Ah, that explains much, I did the big reorg -> trunk move and forgot to commit
some things, so here they are, after being manually copied.
Diffstat (limited to '')
-rw-r--r--src/tests/socketblock.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tests/socketblock.cpp b/src/tests/socketblock.cpp
new file mode 100644
index 0000000..443b07e
--- /dev/null
+++ b/src/tests/socketblock.cpp
@@ -0,0 +1,50 @@
1#include "bu/ito.h"
2#include "bu/socket.h"
3#include "bu/serversocket.h"
4#include <stdio.h>
5
6class TstServer : public Bu::Ito
7{
8public:
9 TstServer() :
10 s( 55678 )
11 {
12 }
13
14 virtual void *run()
15 {
16 Bu::Socket c = s.accept( 45, 0 );
17 printf("TstServer: Accetped connection.\n"); fflush( stdout );
18
19 sleep( 1 );
20 printf("TstServer: Trying to read 10 bytes...\n"); fflush( stdout );
21
22 char buf[10];
23 size_t nRead = c.read( buf, 10 );
24 printf("TstServer: Got %d bytes...\n", nRead ); fflush( stdout );
25
26 printf("TstServer: Closing connection...\n"); fflush( stdout );
27 c.close();
28
29 return NULL;
30 }
31
32 Bu::ServerSocket s;
33};
34
35int main()
36{
37 TstServer ts;
38
39 ts.start();
40
41 printf("main: Connecting to server.\n"); fflush( stdout );
42 Bu::Socket s( "localhost", 55678 );
43
44 printf("main: Sending 4 bytes.\n"); fflush( stdout );
45 s.write( "aoeu", 4 );
46
47 printf("main: Sleeping 10 seconds for good measure.\n"); fflush( stdout );
48 sleep( 10 );
49}
50