00001 
00002 
00003 
00004 
00005 
00006 
00007 #include <iostream>
00008 #include <boost/asio.hpp>
00009 
00010 #include <socket.h>
00011 #include <DEBUG.h>
00012 
00013 using namespace FastEcslent;
00014 
00015 
00016 boost::asio::ip::udp::socket* FastEcslent::makeUDPBroadcastSocket (){
00017 
00018                 boost::asio::io_service netService;
00019                 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028                 boost::asio::ip::udp::socket* socket;
00029                 try {
00030                         socket = new boost::asio::ip::udp::socket(netService);
00031                         socket->open(boost::asio::ip::udp::v4());
00032                         DEBUG(std::cout << "Opened Socket" << std::endl;)
00033 
00034                         boost::asio::socket_base::reuse_address option1(true);
00035                         socket->set_option(option1);
00036                         boost::asio::socket_base::broadcast option2(true);
00037                         socket->set_option(option2);
00038 
00039                         boost::asio::socket_base::receive_buffer_size option(65536);
00040                         socket->set_option(option);
00041                         boost::asio::socket_base::receive_buffer_size option3;
00042                         socket->get_option(option3);
00043 
00044 
00045                         DEBUG(std::cout << "Socket receive buffer size: " << option3.value() << std::endl;)
00046                 } catch (std::exception &e) {
00047                         DEBUG(std::cerr << "Exception in creating socket: " << e.what() << std::endl;)
00048                 }
00049                 return socket;
00050 }
00051 
00052