summaryrefslogtreecommitdiff
path: root/src/tests/socketblock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/socketblock.cpp')
-rw-r--r--src/tests/socketblock.cpp56
1 files changed, 0 insertions, 56 deletions
diff --git a/src/tests/socketblock.cpp b/src/tests/socketblock.cpp
deleted file mode 100644
index e36bb33..0000000
--- a/src/tests/socketblock.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/ito.h"
9#include "bu/tcpsocket.h"
10#include "bu/tcpserversocket.h"
11#include <stdio.h>
12#include <unistd.h>
13
14class TstServer : public Bu::Ito
15{
16public:
17 TstServer() :
18 s( 55678 )
19 {
20 }
21
22 virtual void run()
23 {
24 Bu::TcpSocket c = s.accept( 45, 0 );
25 printf("TstServer: Accetped connection.\n"); fflush( stdout );
26
27 sleep( 1 );
28 printf("TstServer: Trying to read 10 bytes...\n"); fflush( stdout );
29
30 char buf[10];
31 size_t nRead = c.read( buf, 10 );
32 printf("TstServer: Got %d bytes...\n", nRead ); fflush( stdout );
33
34 printf("TstServer: Closing connection...\n"); fflush( stdout );
35 c.close();
36 }
37
38 Bu::TcpServerSocket s;
39};
40
41int main()
42{
43 TstServer ts;
44
45 ts.start();
46
47 printf("main: Connecting to server.\n"); fflush( stdout );
48 Bu::TcpSocket s( "localhost", 55678 );
49
50 printf("main: Sending 4 bytes.\n"); fflush( stdout );
51 s.write( "aoeu", 4 );
52
53 printf("main: Sleeping 10 seconds for good measure.\n"); fflush( stdout );
54 sleep( 10 );
55}
56