forked from premiere/premiere-libtorrent
broadcast socket fix
This commit is contained in:
parent
5b2f1d70e8
commit
29ccb9220b
|
@ -71,6 +71,7 @@ namespace libtorrent
|
|||
udp::endpoint remote;
|
||||
void close()
|
||||
{
|
||||
if (!socket) return;
|
||||
asio::error_code ec;
|
||||
socket->close(ec);
|
||||
}
|
||||
|
|
|
@ -187,12 +187,17 @@ namespace libtorrent
|
|||
for (std::list<socket_entry>::iterator i = m_unicast_sockets.begin()
|
||||
, end(m_unicast_sockets.end()); i != end; ++i)
|
||||
{
|
||||
if (!i->socket) continue;
|
||||
asio::error_code e;
|
||||
i->socket->send_to(asio::buffer(buffer, size), m_multicast_endpoint, 0, e);
|
||||
#ifndef NDEBUG
|
||||
// std::cerr << " sending on " << i->socket->local_endpoint().address().to_string() << std::endl;
|
||||
#endif
|
||||
if (e) ec = e;
|
||||
if (e)
|
||||
{
|
||||
i->socket->close(e);
|
||||
i->socket.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,6 +206,7 @@ namespace libtorrent
|
|||
{
|
||||
if (ec || bytes_transferred == 0 || !m_on_receive) return;
|
||||
m_on_receive(s->remote, s->buffer, bytes_transferred);
|
||||
if (!s->socket) return;
|
||||
s->socket->async_receive_from(asio::buffer(s->buffer, sizeof(s->buffer))
|
||||
, s->remote, bind(&broadcast_socket::on_receive, this, s, _1, _2));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue