00001
00002
00003
00004
00005
00006
00007 #include <iostream>
00008 #include <cstdlib>
00009 #include <string>
00010 #include "ComPlusPlus/ComPlusPlus"
00011
00012 int main (int argc, char *argv [] ) {
00013
00014 if ( argc != 3 ) {
00015 std::cout << "Usage " << argv[0] << " port host \n";
00016 return 1;
00017 }
00018 int port = std::atoi(argv [1]);
00019 std::string Host = argv [2];
00020
00021
00022 try {
00023 compp::SocketUdp Client;
00024
00025
00026 Client.SetSockOptBroadcast(true);
00027
00028
00029 std::string s = "Broadcasting with Sendto!\n";
00030 Client.Sendto(s.c_str(), s.length(), Host.c_str() , port);
00031 Client.Close();
00032 } catch ( syspp::ComException e ) {
00033 std::cout << "Exception " << e.what() << "\n" ;
00034 }
00035 return 0;
00036 }