00001
00002
00003
00004
00005
00006
00007 #include <iostream>
00008 #include <cstdlib>
00009
00010 #include "SysPlusPlus/SysPlusPlus"
00011 #include "ComPlusPlus/ComPlusPlus"
00012
00013
00014 int main ( int argc, char *argv [] ) {
00015
00016 if ( argc != 3 ) {
00017 std::cout << "Usage: " << argv [0] << " IP-ADDR Port\n";
00018 exit(1);
00019 }
00020
00021 int CPort = std::atoi ( argv[2] );
00022 char buf [10000 ];
00023 std::memset( (void*)buf, 0, sizeof ( buf ) );
00024
00025 try {
00026 compp::SocketUdp Srv;
00027 Srv.SetSockOptReuseAddress ( true);
00028 Srv.SetSockOptBroadcast ( true);
00029
00030 Srv.Bind( argv[1], CPort );
00031
00032 Srv.Recv(buf, sizeof(buf),0);
00033 std::cout << "---" << buf << "---\n";
00034
00035 } catch ( syspp::ComException e ) {
00036 std::cout << "Exception " << e.what( ) << "\n" ;
00037
00038 }
00039 return 0;
00040 }