c++ - Boost.Asio IPv6 Why bind error? -


i want use ipv6 using boost asio in linux (fedora).

nic is

ifconfig -a em1: flags=4163<up,broadcast,running,multicast>  mtu 1500         inet 172.16.16.109  netmask 255.255.255.0  broadcast 172.16.16.255         inet6 fe80::215:17ff:fe62:d168  prefixlen 64  scopeid 0x20<link>         ether 00:15:17:62:d1:68  txqueuelen 1000  (ethernet)         rx packets 59516986  bytes 7105720351 (6.6 gib)         rx errors 0  dropped 5015310  overruns 0  frame 0         tx packets 8680244  bytes 1666346667 (1.5 gib)         tx errors 0  dropped 0 overruns 0  carrier 0  collisions 0         device interrupt 18  memory 0xb8820000-b8840000 

and ipv6 udp bind code is...

int main(int argc, char* argv[]) {     try     {         boost::asio::io_service io_service;          const char* ip_address_string = "fe80::215:17ff:fe62:d168";         // const char* ip_address_string = "::1";  // it's ok         boost::asio::ip::address my_address = boost::asio::ip::address::from_string(ip_address_string);         udp::endpoint local_endpoint(my_address, 15060);          udp my_protocol = udp::v6();         udp::socket sock(io_service);         sock.open(my_protocol);         sock.bind(local_endpoint);          std::cout << "ip:" << local_endpoint.address().to_string() << std::endl;         // -*/      }     catch (std::exception& e)     {         std::cerr << e.what() << std::endl;     }      return 0; } 

binding of v6 loopback address ok, specific ("fe80::215:17ff:fe62:d168") address binding error.

exception error "bind: invalid argument".

why binding error?

it looks might not have permission access external network adaptor.

perhaps (parts of)

  • ipv6 have been disabled (even though adaptor capable , configured)
  • /proc not mounted (are in restricted environment, chroot jail?);
  • the ip address different - bit of lame one, since you'll have checked bazillion times, felt should @ least mention it

now, try in environments fewer restrictions (e.g. outside virtualization containers, root...).

if doesn't information need consider using strace or ltrace see syscalls failing.


your code ok, i've tested work on linux , msvc (substituting nic addresses)


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -