aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-01-20 15:36:24 +0000
committerMike Buland <eichlan@xagasoft.com>2011-01-20 15:36:24 +0000
commit400f12a9d100d48509a48188fcff7f1b820d5826 (patch)
tree4f83145ea62926da06561c287d9a78ffd6f36bba /src/tests
parente3bd8a39947097a3130a4064a4b1ff6981a03c63 (diff)
downloadlibbu++-400f12a9d100d48509a48188fcff7f1b820d5826.tar.gz
libbu++-400f12a9d100d48509a48188fcff7f1b820d5826.tar.bz2
libbu++-400f12a9d100d48509a48188fcff7f1b820d5826.tar.xz
libbu++-400f12a9d100d48509a48188fcff7f1b820d5826.zip
Ummm...it's a udpsocket, mostly. It seems like it should work, but early tests
are failing...
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/udpsocket.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/udpsocket.cpp b/src/tests/udpsocket.cpp
new file mode 100644
index 0000000..63aa576
--- /dev/null
+++ b/src/tests/udpsocket.cpp
@@ -0,0 +1,41 @@
1#include "bu/udpsocket.h"
2#include "bu/sio.h"
3
4using namespace Bu;
5
6int main( int argc, char *argv[] )
7{
8 if( argv[1][0] == 'l' )
9 {
10 sio << "Listening..." << sio.nl;
11 Bu::UdpSocket udp( "255.255.255.255", 6688, UdpSocket::Read|UdpSocket::Broadcast );
12
13 for(;;)
14 {
15 char buf[1501];
16 int iRead = udp.read( buf, 1500 );
17 buf[iRead] = '\0';
18 sio << "Read(" << iRead << "): '" << buf << "'";
19 }
20 }
21 else if( argv[1][0] == 'b' )
22 {
23 sio << "Broadcasting..." << sio.nl;
24 Bu::UdpSocket udp("255.255.255.255", 6688,
25 UdpSocket::Write|UdpSocket::Broadcast );
26
27 for(;;)
28 {
29 udp.write("hello", 5 );
30 usleep( 250000 );
31 }
32 }
33 else
34 {
35 sio << "Options are 'l' for listening and 'b' for broadcasting."
36 << sio.nl;
37 }
38
39 return 0;
40}
41