From 400f12a9d100d48509a48188fcff7f1b820d5826 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 20 Jan 2011 15:36:24 +0000 Subject: Ummm...it's a udpsocket, mostly. It seems like it should work, but early tests are failing... --- src/tests/udpsocket.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/tests/udpsocket.cpp (limited to 'src/tests') 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 @@ +#include "bu/udpsocket.h" +#include "bu/sio.h" + +using namespace Bu; + +int main( int argc, char *argv[] ) +{ + if( argv[1][0] == 'l' ) + { + sio << "Listening..." << sio.nl; + Bu::UdpSocket udp( "255.255.255.255", 6688, UdpSocket::Read|UdpSocket::Broadcast ); + + for(;;) + { + char buf[1501]; + int iRead = udp.read( buf, 1500 ); + buf[iRead] = '\0'; + sio << "Read(" << iRead << "): '" << buf << "'"; + } + } + else if( argv[1][0] == 'b' ) + { + sio << "Broadcasting..." << sio.nl; + Bu::UdpSocket udp("255.255.255.255", 6688, + UdpSocket::Write|UdpSocket::Broadcast ); + + for(;;) + { + udp.write("hello", 5 ); + usleep( 250000 ); + } + } + else + { + sio << "Options are 'l' for listening and 'b' for broadcasting." + << sio.nl; + } + + return 0; +} + -- cgit v1.2.3