From 4b9289cfb260f4bcecaf23a810584ef6ef8e8501 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 30 Mar 2011 22:33:41 +0000 Subject: Ok, string stuff is working much, much better, a load of new unit tests have been added, and I deleted a whole slew of stupid old tests that I don't need. --- src/tests/udpsocket.cpp | 86 ------------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 src/tests/udpsocket.cpp (limited to 'src/tests/udpsocket.cpp') diff --git a/src/tests/udpsocket.cpp b/src/tests/udpsocket.cpp deleted file mode 100644 index 2a74acf..0000000 --- a/src/tests/udpsocket.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2007-2011 Xagasoft, All rights reserved. - * - * This file is part of the libbu++ library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "bu/udpsocket.h" -#include "bu/sio.h" - -#include -#include -#include -#include -#include - -using namespace Bu; - -int main( int argc, char *argv[] ) -{ - sio << Fmt::hex(8) << INADDR_ANY << sio.nl << Fmt::hex(8) << inet_addr("0.0.0.0") << sio.nl; - if( argc == 1 ) - { - sio << "Options are 'l' for listening and 'b' for broadcasting." - << sio.nl; - } - else if( argv[1][0] == 'l' ) - { - sio << "Listening..." << sio.nl; - Bu::UdpSocket udp( "0.0.0.0", 6688, UdpSocket::Read|UdpSocket::Broadcast ); - - for(;;) - { - char buf[1501]; - int iRead = udp.read( buf, 1500 ); - if( iRead >= 0 ) - { - buf[iRead] = '\0'; - sio << "Read(" << iRead << "): '" << buf << "'" << sio.nl; - } - else - { - sio << "Got " << iRead << ": " << strerror( errno ) << sio.nl; - } - } - } - else if( argv[1][0] == 'L' ) - { - sio << "Listening..." << sio.nl; - Bu::UdpSocket udp( "0.0.0.0", 6688, UdpSocket::Read|UdpSocket::Broadcast ); - - for(;;) - { - char buf[1501]; - Bu::UdpSocket::addr aHost; - int iPort; - int iRead = udp.read( buf, 1500, aHost, iPort ); - if( iRead >= 0 ) - { - buf[iRead] = '\0'; - sio << "Read(" << iRead << ") from " << Bu::UdpSocket::addrToStr( aHost ) << ":" << iPort << ": '" << buf << "'" << sio.nl; - } - } - } - else if( argv[1][0] == 'b' ) - { - sio << "Broadcasting..." << sio.nl; - Bu::UdpSocket udp("255.255.255.255", 6688, - UdpSocket::Write|UdpSocket::Broadcast ); - - for(;;) - { - int iWrote = udp.write("hello", 5 ); - sio << "Wrote(" << iWrote << "): " << strerror( errno ) << sio.nl; - usleep( 250000 ); - } - } - else - { - sio << "Options are 'l' for listening and 'b' for broadcasting." - << sio.nl; - } - - return 0; -} - -- cgit v1.2.3