DragonFly users List (threaded) for 2013-07
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Socket ipv6-only option
--nextPart2745007.gkzDpVikVZ
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
I'm writing a program that sends UDP packets to another instance of the
program. It now sends a test packet to all results of a resolver query. I run
it on darner (DragonFly) and caracal (Linux) and tell them to send packets to
each other. I see two differences between the two OSes:
*On darner, the resolver returns only the IPv6 address of caracal, though
running host returns both. On caracal, it returns both addresses of darner.
*On darner, the socket comes up in IPv6-only mode. On caracal, it accepts IPv4
packets (I checked this by telling caracal to send to caracal). Telling
caracal to send to darner's IPv4 address results in no packets received.
I tried to clear the IPv6-only option; this causes an abort on both OSes.
Stepping through it on DragonFly, I see that the error code returned from the
setsockopt call is 2.
Attempting to declare separate sockets for IPv4 and IPv6 results in "Address
already in use", at least in Linux.
Pierre
--
I believe in Yellow when I'm in Sweden and in Black when I'm in Wales.
--nextPart2745007.gkzDpVikVZ
Content-Disposition: attachment; filename="network.cpp"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-c++src; charset="UTF-8"; name="network.cpp"
#include <boost/asio.hpp>
#include <cstdio>
#include <string>
#include <fstream>
#include "network.h"
using namespace std;
using namespace boost::asio;
io_service io;
ip::udp::socket sendsocket(io,ip::udp::endpoint(ip::udp::v6(),0)), receivesocket(io,ip::udp::endpoint(ip::udp::v6(),2375));
void initnetwork()
{
int i,nrecv;
boost::system::error_code error;
char recvbuffer[MTU];
fstream conf("ampelos.conf");
string msg("udp test");
string otherend;
ip::udp::endpoint endpoint;
ip::udp::resolver resolver(io);
conf>>otherend;
ip::udp::resolver::query query(otherend,"2375");
ip::udp::resolver::iterator iter=resolver.resolve(query);
ip::udp::resolver::iterator end;
//receivesocket.non_blocking(true);
socket_base::non_blocking_io command(true);
receivesocket.io_control(command);
ip::v6_only option(false);
//receivesocket.set_option(option);
while (iter!=end)
{
endpoint=*iter++;
cout<<endpoint<<endl;
sendsocket.send_to(buffer(msg),endpoint);
}
for (i=0;i<15;i++)
{
nrecv=receivesocket.receive_from(buffer(recvbuffer,MTU),endpoint,0,error);
if (nrecv)
cout<<nrecv<<" "<<endpoint<<endl;
else
sleep(1);
}
}
--nextPart2745007.gkzDpVikVZ--
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]