Skip to content

Can't bind udp socket to link-local address #376

@misuzu

Description

@misuzu

This code panics:

extern crate mio;

use std::net::{SocketAddr, SocketAddrV6};

use mio::Ipv6Addr;
use mio::udp::UdpSocket;

fn main() {
    let socket = UdpSocket::v6().unwrap();
    socket.bind(&SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::new(0xfe80, 0, 0, 0, 0xbe5f, 0xf4ff, 0xfee9, 0x35df), 0xfc00, 0, 2))).unwrap();
}
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 99, message: "Cannot assign requested address" } }', ../src/libcore/result.rs:746
stack backtrace:
   1:     0x55dd2f317cc0 - sys::backtrace::tracing::imp::write::h3bbb320d569781f92cv
   2:     0x55dd2f319e1f - panicking::default_handler::_$u7b$$u7b$closure$u7d$$u7d$::closure.44520
   3:     0x55dd2f319a98 - panicking::default_handler::hf1209fec3f963ae7H0z
   4:     0x55dd2f313e8c - sys_common::unwind::begin_unwind_inner::h2ff9ae045f111c6dg2t
   5:     0x55dd2f314518 - sys_common::unwind::begin_unwind_fmt::hf803f209d02109a7m1t
   6:     0x55dd2f317271 - rust_begin_unwind
   7:     0x55dd2f34ecbf - panicking::panic_fmt::hd76b622b6f659cc5FRL
   8:     0x55dd2f30f8cb - result::unwrap_failed::h7652535341612392168
                        at ../src/libcore/macros.rs:29
   9:     0x55dd2f30fc14 - result::Result<T, E>::unwrap::h4570724438596938202
                        at ../src/libcore/result.rs:687
  10:     0x55dd2f30f529 - main::h1076113ec20c8e6fkaa
                        at src/main.rs:50
  11:     0x55dd2f3196f4 - sys_common::unwind::try::try_fn::h12478214143095739015
  12:     0x55dd2f3171fb - __rust_try
  13:     0x55dd2f31918b - rt::lang_start::h4f110050dd8fc253NSz
  14:     0x55dd2f30fd19 - main
  15:     0x7f692343086f - __libc_start_main
  16:     0x55dd2f30f328 - _start
  17:                0x0 - <unknown>

Same on python is just fine:

Python 2.7.11+ (default, Feb 22 2016, 16:38:42)
[GCC 5.3.1 20160220] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>>
>>> s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
>>> s.bind(('fe80::be5f:f4ff:fee9:35df', 0xfc00, 0, 2))
>>>

Using mio from git.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions