Skip to content

Commit

Permalink
lan plugin config option for transmitting duplicate packets
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ committed Jul 18, 2009
1 parent c0d064f commit eaffd19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
9 changes: 7 additions & 2 deletions resolvers/lan/README.txt
Expand Up @@ -2,13 +2,15 @@ The LAN plugin broadcasts searches using UDP multicast.
Results are streamed over HTTP using the address the UDP result came from. Results are streamed over HTTP using the address the UDP result came from.
It should just automatically work on home/small office networks. It should just automatically work on home/small office networks.
-- --
By default you don't need anything in the config file for this plugin, however: By default you don't need anything in the config file for this plugin, however
the following options are valid if you need any of them:


"lan" : "lan" :
{ {
"listenip" : "your.lan.ip.address", "listenip" : "your.lan.ip.address",
"listenport" : 8888, "listenport" : 8888,
"endpoints" : ["239.255.0.1", "10.1.2.3", "192.168.1.1"] "endpoints" : ["239.255.0.1", "10.1.2.3", "192.168.1.1"],
"numcopies" : 3
} }


* If you change the "listenport", it'll only work with others on the same port. * If you change the "listenport", it'll only work with others on the same port.
Expand All @@ -23,3 +25,6 @@ By default you don't need anything in the config file for this plugin, however:
machine you can reach on the LAN, despite multicast not working. machine you can reach on the LAN, despite multicast not working.


* to change endpoint ports too: "endpoints" : [ ["10.1.2.3",1234], [..] ] * to change endpoint ports too: "endpoints" : [ ["10.1.2.3",1234], [..] ]

* for lossy networks, set copies to more than 1, so your UDP packets stand a
better chance of being received. default is 1.
25 changes: 16 additions & 9 deletions resolvers/lan/lan.cpp
Expand Up @@ -219,15 +219,22 @@ lan::async_send(boost::asio::ip::udp::endpoint * remote_endpoint,
//cout << "UDPsend[" << remote_endpoint.address() //cout << "UDPsend[" << remote_endpoint.address()
// << ":" << remote_endpoint.port() << "]" // << ":" << remote_endpoint.port() << "]"
// << "(" << message << ")" << endl; // << "(" << message << ")" << endl;
char * buf = (char*)malloc(message.length());
memcpy(buf, message.data(), message.length()); // you can set numcopies to 2 or 3 for lossy networks:
socket_->async_send_to( int copies = m_pap->get<int>("plugins.lan.numcopies", 1);
boost::asio::buffer(buf,message.length()), if(copies<1) copies=1;
*remote_endpoint, for(int j = 0; j<copies; j++)
boost::bind(&lan::handle_send, this, {
boost::asio::placeholders::error, char * buf = (char*)malloc(message.length());
boost::asio::placeholders::bytes_transferred, memcpy(buf, message.data(), message.length());
buf)); socket_->async_send_to(
boost::asio::buffer(buf,message.length()),
*remote_endpoint,
boost::bind(&lan::handle_send, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred,
buf));
}
} }


void lan::handle_send( const boost::system::error_code& error, void lan::handle_send( const boost::system::error_code& error,
Expand Down

0 comments on commit eaffd19

Please sign in to comment.