|
Boost Users : |
Subject: Re: [Boost-users] UDP bind problems
From: ustulation (ustulation_at_[hidden])
Date: 2014-01-13 13:21:56
did you actually read the question (the 1st post in the forum under
this topic)? I have written the code explicitly there:
if(!m_udpSocket.is_open())
{
m_udpSocket.open(m_localEndpoint.protocol(), errorCode);
//m_localEndpoint is address 0.0.0.0 and port X
if(errorCode)
{
std::cerr << "Unable to open socket: " << errorCode.message()
<< std::endl;
}
else
{
m_udpSocket.set_option(boost::asio::socket_base::reuse_address(true),
errorCode);
if(errorCode)
{
std::cerr << "Reuse address option set failure. " <<
errorCode.message() << std::endl;
}
m_udpSocket.set_option(boost::asio::socket_base::broadcast(true),
errorCode);
if(errorCode)
{
std::cerr << "Socket cannot send broadcast. " <<
errorCode.message() << std::endl;
}
else
{
m_udpSocket.bind(m_localEndpoint, errorCode);
if(errorCode)
{
std::cerr << "Socket cannot bind...!! " <<
errorCode.message() << std::endl;
}
}
}
}
Do you mean there's anything wrong with this?
On Mon, Jan 13, 2014 at 11:42 PM, Cliff Green-3 [via Boost]
<ml-node+s2283326n4657774h92_at_[hidden]> wrote:
>>> {boost::asio::ip::address::from_string("255.255.255.255"), Y}; //Y=some
>>> unsigned short
>>> Is this wrong? But why would it affect binding and stuff anyway?
>
> You must set the broadcast socket option to send to a broadcast address
> (check out the Asio socket options).
>
> Cliff
>
>
>
>
>
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://boost.2283326.n4.nabble.com/UDP-bind-problems-tp4657731p4657774.html
> To unsubscribe from UDP bind problems, click here.
> NAML
-- ------------ spandan sharma -- View this message in context: http://boost.2283326.n4.nabble.com/UDP-bind-problems-tp4657731p4657776.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net