Code Monkey home page Code Monkey logo

net2-rs's Introduction

net2

Extensions to the standard library's networking types, proposed in RFC 1158.

Build Status Documentation

net2 is Deprecated

Prospective and existing consumers are encouraged to consider socket2 instead.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

net2-rs's People

Contributors

alexcrichton avatar badboy avatar bluejekyll avatar cactorium avatar canndrew avatar carllerche avatar danieldg avatar dholbert avatar doumanash avatar faern avatar flba-eb avatar hlzhang avatar jackpot51 avatar jd91mzm2 avatar kallisti5 avatar lhecker avatar ltratt avatar mattico avatar mehcode avatar mneumann avatar nbaksalyar avatar nielx avatar pfmooney avatar rrichardson avatar rylev avatar sateffen avatar sfackler avatar simonsapin avatar steffengy avatar tones111 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

net2-rs's Issues

[cargo-web] Compile error on linux

I can't build the net2 project with cargo-web, but I can build the net2 project with cargo. The error information as following:

zmant@zmant-PC:~/.cargo/registry/src/code.aliyun.com-738b7dba08a2a41e/net2-0.2.33$ cargo-web build --release
   Compiling cfg-if v0.1.9
   Compiling net2 v0.2.33 (/home/zmant/.cargo/registry/src/code.aliyun.com-738b7dba08a2a41e/net2-0.2.33)
error[E0432]: unresolved import `sys`
  --> src/tcp.rs:18:5
   |
18 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?
error[E0432]: unresolved import `sys`
  --> src/udp.rs:18:5
   |
18 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?
error[E0432]: unresolved import `sys`
  --> src/socket.rs:22:5
   |
22 | use sys;
   |     ^^^ no `sys` in the root
error[E0432]: unresolved import `sys`
  --> src/socket.rs:23:5
   |
23 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?
error[E0432]: unresolved import `sys`
  --> src/ext.rs:19:5
   |
19 | use sys;
   |     ^^^ no `sys` in the root
error[E0432]: unresolved import `sys`
  --> src/ext.rs:20:5
   |
20 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?
error[E0412]: cannot find type `c_int` in this scope
.........
error[E0046]: not all trait items implemented, missing: `send`, `recv`
   --> src/ext.rs:970:1
    |
621 |     fn send(&self, buf: &[u8]) -> io::Result<usize>;
    |     ------------------------------------------------ `send` from trait
...
628 |     fn recv(&self, buf: &mut [u8]) -> io::Result<usize>;
    |     ---------------------------------------------------- `recv` from trait
...
970 | impl UdpSocketExt for UdpSocket {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `send`, `recv` in implementation

error: aborting due to 243 previous errors
Some errors occurred: E0046, E0412, E0422, E0425, E0432.
For more information about an error, try `rustc --explain E0046`.
error: Could not compile `net2`.

To learn more, run the command again with --verbose.
error: build failed

Probability of recurrence:100%.
Any one can help me? thanks very much!!!

Fail Compilation with Rust Nightly.

net2 is a dependent crate for hyper- Rust http library. I'm trying to compile the hyper crate with the Rust nightly compiler but the error messages I'm getting seems to be coming from this crate.

error[E0432]: unresolved import sys
--> /home/myUsername/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/tcp.rs:18:5
|
18 | use sys::c;
| ^^^ Maybe a missing extern crate sys;?

error[E0432]: unresolved import sys
--> /home/myUsername/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/udp.rs:18:5
|
18 | use sys::c;
| ^^^ Maybe a missing extern crate sys;?

There is at least 245 similar errors from this crate.

Consider adding support for SO_REUSEPORT

Some sources on the web claim that setting SO_REUSEPORT is required on newer versions of OS/X to allow binding multiple UDP multicast sockets to the same port. This would be a difference to Linux, where SO_REUSEADDR is used for the same purpose. I don't have a OS/X system and can't verify this, but I think you should consider adding support for SO_REUSEPORT.

Sources:

POSIX interface

Hey-o!

Not sure if this is the place to for this, but figured anyone in the community caring about the evolution of std::net is probably using this crate and will be here.

It took me a bit too long to figure out this crate was around, and that RFC 1158 was a thing. It appears this crate has been baking for a bit with the standard Rusty style API with the addition of the Builder-like API. Is it too late to recommend that std::net should provide a safe Socket wrapper that exposes a POSIX style API (POSIX sockets won the network API war, even Microsoft conforms) in order to make interfacing with current lower level system network code a little less cumbersome to work with?

For any serious networking application with OS level options, you already have to pull out the inner and do unsafe operations from the libc crate, or with your own shims. Also, because of the current std::net::TcpStream and friends wrapping a FileDesc and using F_DUPFD when cloning, it can make for some unexpected weirdness when interacting with other system level interfaces expecting fds.

I only ask because I'm already on the path of making this a thing, but really just for Unix. But if there is interest, or it would be worth it, I wouldn't mind putting those efforts into this crate with a PR or RFC or whatever and also including the Win calls. The API surface I have in mind would be everything here minus recvmsg/sendmsg because of the heavy use of C macros associated with setting those data structures up properly. Most of the flags and functions are available through current libc/winapi crates, with the remaining only a few PRs away to keep from hard-coding flags. If this is also too big of a change (Obv it will be breaking), I can do a RFC along with the PR as well?

Introduce Raw Socket public API

subj
Does it sound good idea to introduce such API?

Current Socket struct is pretty much for internal use, but what about letting user access it by making it public?

Add SO_LINGER option

Hey,

because I didn't submit a pull-request (hopefully yet, up till now I'm missing time) I want to add this issue as reminder. Maybe someone else wants to implement this, but I think it has to be implemented at some point (and yes, you can implement it as well, I don't mind)

According to linux and windows documentation, this is just passing a struct looking like

struct linger {
    int l_onoff;    /* linger active */
    int l_linger;   /* how many seconds to linger for */
};

as optval for SO_LINGER. This should work cross plattform as far as I know.

I think the API should take a duration and convert that in an on-off version of the struct. What do you guys think?

Publish new patch

Tokio-proto currently assumes the unix submodule is available on android, so it would be good if we could get a patch released including commit 1ccd25d so tokio-proto can (hopefully) compile for android.

set_keepalive reports EINVAL on Linux

Linux is Ubuntu with 3.13.0-63-generic kernel, x86_64.

Error debug message is

Error { repr: Os { code: 22, message: "Invalid argument" } }

The same code runs well on OS X 10.10.5.

Call from the mio::tcp::TcpStream::set_keepalive with argument Some(300).

support TCP_KEEP{CNT,INTVL} on Linux

The support for keepalive is pretty limited right now. I'm looking to write a test that wants to trigger connection closure in response to unacked timeouts, and without being able to set these, it's impossible for that test to complete in a reasonable amount of time.

OpenBSD does not support TCP_KEEPALIVE or a timeout with SO_KEEPALIVE

Hi,

using net2 on OpenBSD, I've stumbled over this:

 24878 arca-broker CALL  setsockopt(23,SOL_SOCKET,SO_KEEPALIVE,0x1f005a366034,4)
 24878 arca-broker RET   setsockopt 0
 24878 arca-broker CALL  setsockopt(23,6<unknown>,8,0x1f005a366034,4)
 24878 arca-broker RET   setsockopt -1 errno 1 Operation not permitted
 24878 arca-broker CALL  close(23)

The first setsockopt() call is enabling SO_KEEPALIVE, which is OK and supported, the second setsockopt() call is trying to set the timeout with IPPROTO_TCP (6) and TCP_KEEPALIVE (mapped to SO_KEEPALIVE == 8).

Using SO_KEEPALIVE/TCP_KEEPALIVE on a IPPROTO_TCP level is not supported on OpenBSD. OpenBSD only supports global sysctl settings for setting the keepalive intervals:

net.inet.tcp.keepinittime=150
net.inet.tcp.keepidle=14400
net.inet.tcp.keepintvl=150
net.inet.tcp.always_keepalive=0

This mapping is invalid on OpenBSD...:
https://github.com/rust-lang-nursery/net2-rs/blob/a3d51b36da8dfbc62e0df2219662537e110aeb59/src/ext.rs#L661

...as it is used here:
https://github.com/rust-lang-nursery/net2-rs/blob/master/src/ext.rs#L735-L736

...and here:
https://github.com/rust-lang-nursery/net2-rs/blob/master/src/ext.rs#L748-L749

Refactor ext.rs

Hey a second time,

on my way checking how to implement #42 I saw that I just have to add some code to the ext.rs, but this file is... Hilarious. It's so long, that it's very difficult to check what I've done already, even going from top to bottom.

Is there a special reason, why this file is so super long? Is there a chance to refactor this in separated files, so it gets simpler to maintain? I think it would help a lot.

`TcpListener.incoming()` incorrectly reports an error in Windows

Similar code as in #2

incoming() returns an Err with code 0 and message "The operation completed successfully.\r\n". This should be an Ok instead.

extern crate net2;
use net2::TcpBuilder;

use std::net::TcpStream;
// use std::net::TcpListener;
use std::io::{Write, Read};
use std::thread;

fn start_server() {
    let listener = TcpBuilder::new_v4().unwrap().bind("127.0.0.1:16379").unwrap().listen(200).unwrap();
    // let listener = TcpListener::bind("127.0.0.1:16379").unwrap();

    for stream in listener.incoming() {
        match stream {
            Ok(mut stream) => {
                thread::spawn(move|| {
                    // connection succeeded
                    let mut v = [0u8; 512];
                    println!("handling client {:?}", stream.read(&mut v));
                });
            }
            Err(e) => { println!("error {:?}", e); }
        }
    }
    // close the socket server
    drop(listener);
}

fn start_client() {
    let mut stream = TcpStream::connect("127.0.0.1:16379").unwrap();
    let _ = stream.write(&[1,2,3]);
}

#[test]
fn t() {
    assert!(TcpStream::connect("127.0.0.1:16379").is_err()); // workaround for issue #2
    thread::spawn(|| start_server());
    thread::sleep_ms(1000);
    start_client();
    thread::sleep_ms(1000);
}

TCP keepalive functionality isn't ideal

I discovered during the implementation of RFC 1461 that we should tweak the APIs that we expose related to TCP keepalive. Right now we have a getter and setter for an Option<Duration>, but there are two problems with this:

  • There are two distinct operations at the socket level that are being conflated - enabling keepalive and customizing the associated interval. We'd probably want to separate these out.
  • You can't retrieve the keepalive interval on Windows.

Publish 0.2.4

Since net2 is broken in nightly, it'd be nice to have 0.2.4 released.

On the other hand, I tried to work around by pointing my Cargo.toml to this repository, but it doesn't seem to detect the nightly feature. Should this work?

-[dependencies]
-net2 = { version = "0.2.2", features = ["nightly"] }
+[dependencies.net2]
+net2 = { git = "https://github.com/alexcrichton/net2-rs", features = ["nightly"] }

The error I'm getting:

src/lib.rs:71:35: 71:62 error: no associated item named `set_keepalive` found for type `net2::ext::TcpStreamExt` in the current scope
src/lib.rs:71             Stream::Tcp(ref s) => TcpStreamExt::set_keepalive(s, duration),
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks

Compile error on OS X

Trying to use this crate in Mac OS X produces the following error:

/Users/seppo/.cargo/registry/src/github.com-0a35038f75765ae4/net2-0.1.0/src/ext.rs:164:60: 164:78 error: unresolved name `libc::TCP_KEEPIDLE`
/Users/seppo/.cargo/registry/src/github.com-0a35038f75765ae4/net2-0.1.0/src/ext.rs:164             try!(setopt(self.as_sock(), libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
                                                                                                                                                  ^~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:48 note: in expansion of try!
/Users/seppo/.cargo/registry/src/github.com-0a35038f75765ae4/net2-0.1.0/src/ext.rs:164:13: 165:47 note: expansion site
note: in expansion of if let expansion
/Users/seppo/.cargo/registry/src/github.com-0a35038f75765ae4/net2-0.1.0/src/ext.rs:163:9: 166:10 note: expansion site
/Users/seppo/.cargo/registry/src/github.com-0a35038f75765ae4/net2-0.1.0/src/ext.rs:178:41: 178:59 error: unresolved name `libc::TCP_KEEPIDLE`
/Users/seppo/.cargo/registry/src/github.com-0a35038f75765ae4/net2-0.1.0/src/ext.rs:178                                         libc::TCP_KEEPIDLE));
                                                                                                                               ^~~~~~~~~~~~~~~~~~
<std macros>:1:1: 6:48 note: in expansion of try!
/Users/seppo/.cargo/registry/src/github.com-0a35038f75765ae4/net2-0.1.0/src/ext.rs:177:20: 178:61 note: expansion site
error: aborting due to 2 previous errors

Documentation request for UdpSocketExt

Can you provide an example for sending UDP multicast with UdpSocketExt? I don't know how to list out the Ipv4Addr's on the current host and I think that would useful to new net2 users.

github.com/deprecated-rs maybe?

Why github.com/deprecated? Should this namespace cover other languages than Rust?

If Rust only, then it's better to name it github.com/deprecated-rs.

Fail to doc on nightly

error: `[cfg]` cannot be resolved, ignoring it...
 --> /home/humbug/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.3/src/lib.rs:1:28
  |
1 | //! A macro for defining #[cfg] if-else statements.
  |                            ^^^ cannot be resolved, ignoring
  |
note: lint level defined here
 --> /home/humbug/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/lib.rs:42:23
  |
42| #![deny(missing_docs, warnings)]
  |                       ^^^^^^^^
  = note: #[deny(intra_doc_link_resolution_failure)] implied by #[deny(warnings)]
  = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

error: `[cfg]` cannot be resolved, ignoring it...
 --> /home/humbug/.cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-0.1.3/src/lib.rs:7:59
  |
7 | //! This allows you to conveniently provide a long list #[cfg]'d blocks of code
  |                                                           ^^^ cannot be resolved, ignoring
  |
  = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

error: Could not document `net2`.

Depends on rust-lang/cfg-if#11

More ergonomic API for constructing sockets

I started out wanting to be able to bind a socket to a given address (for the purposes of using a particular network interface) before connecting, and quickly discovered the standard library does not provide methods for doing so. I then found net2::TcpBuilder, which does provide this feature, but found the API somewhat less ergonomic than I would have liked.

@sfackler pointed out that RFC 1461 (after the failed RFC 1158) pulled in a couple of changes from net2 into the standard library, and @seanmonstar that net2 is a "Desired out-of-band evaluation" in the libz blitz, so I figured I'd send some feedback in the hopes that eventually something like TcpBuilder might land in the standard library too.

My suggestions follow below. I'd be happy to file a PR, but @sfackler suggested that given the backwards-incompatibility of these changes, filing a ticket first for discussion would be a good idea. Some of these build on the Builders enable construction of complex values (C-BUILDER) section from @brson's Rust API guidelines, whereas others are just because I like them better. Thoughts and feedback very welcome!

  • The methods on TcpBuilder that modify the socket should all take &mut self, and return that &mut in their Result. This is because, while it is technically true that a socket can be mutated safely from multiple places, it leaves the consumer of the API confused about whether there's a difference between the original builder and the returned one. For instance, it is not clear just from the API (nor from the resulting code) that tcp and tcp2 are the same socket, bound to the same port in the following code:

    let tcp = TcpBuilder::new_v4().unwrap();
    let tcp2 = tcp.bind("0.0.0.0:4000");

    Using &mut self is also more semantically accurate, since it indicates that we are in fact modifying the underlying socket.

  • The methods on TcpBuilder that listen, connect, or otherwise "initiate" the socket, should take self, not &self. The current API implies that you can re-use a builder to construct a second socket after calling listen or connect on it once, but this is not true. The code will panic if you try to do this, presumably because a single socket cannot be re-used. In theory, the builder could remember the configuration, and lazily create and configure the socket when needed, which would enable this kind of API, but I'm not sure that's really better. I think it's fairly rare that you'll want to re-use a socket configuration.

  • The change above brings us back to the first point about &mut self vs &self. @brson's post says that:

    Under the rubric of making easy things easy and hard things possible, all builder methods for a consuming builder should take and returned an owned self.

    Which suggests that we should in fact make all the builder methods take self. This unfortunately combines poorly with the fact that our methods can fail, and thus return Result<Self, ...>. If a method fails, you'd like to still be able to recover the builder, which is tricky if self was consumed. Maybe @brson can provide some insight here?

  • This is a more controversial one, but it might be that we should provide a SocketBuilder rather than a separate TcpBuilder and UdpBuilder. Under the hood, that's what the Berkeley Socket API provides, and it's unclear you want the distinction here either. Instead, you could imagine SocketBuilder being parameterized by UDP/TCP, which would still let us only expose the TCP related methods for TCP sockets. I personally think this would make the API more readable, and it would avoid the complete duplication of methods between the implementations. Along the same lines, I'd prefer to see V4/V6 be an enum passed to new, but I feel less strongly about that particular point.

@seanmonster pointed out that this is unlikely to break existing code, since current implementations must already only be calling the finalizing methods once (since any other use panics). Making the methods take &mut self will also likely require minor or no changes, since they are unlikely to be using the aliased & pointer anyway. Moving to self will require more changes to user code, as the original element will no longer be available, but if the regular one-line builder pattern is used with unwrap (which is unfortunately common), everything will keep working as usual. Dealing with the error cases will be trickier though, and we need a story there.

Here's the original discussion with @seanmonstar, @habnabit, and @sfackler from #rust:
jonhoo: why on earth do all the methods on TcpBuilder in net2 take &self
jonhoo: and return Result&TcpBuilder:
jonhoo: that's a really weird builder pattern
seanmonstar: jonhoo: cause you can mutate the socket without a mutable reference
jonhoo: true, but it's a strange pattern
jonhoo: what does the return value even mean?
jonhoo: for bind() for example, do I need to be using the returned value?
jonhoo: or the original?
jonhoo: or is the original somehow not modified?
sfackler: jonhoo: they're the same pointer
seanmonstar: that was because since all those operations could return an error (they're adjusting options on the socket, not something in rustland)
_habnabit: jonhoo, the return value is for chaining
seanmonstar: it wasn't desirable for you to call build() and get a EINVAL, and be left wondering "well crap, which of those methods had the invalid argument"
jonhoo: sure, but the classic way to do this is to then take `self`
sfackler: jonhoo: no standard library builders work that way iirc
jonhoo: being left with both pointers is weird, because it's not *clear* that they're the same
jonhoo: taking `self` is unambigious
_habnabit: jonhoo, how do you get the socket back out then?
seanmonstar: jonhoo: https://github.com/brson/rust-api-guidelines#builders-enable-construction-of-complex-values-c-builder
seanmonstar: jonhoo: you'd then need it to return ResultTcpStream, (io::Error, TcpStream):
jonhoo: hmm
jonhoo: I see
seanmonstar: otherwise its lost
jonhoo: right right
jonhoo: I still think I'd prefer it taking an `&mut self` even though it's not technically necessary, just to indicate that you are actually modifying the socket (and thus that you can use either the original or the returned)
jonhoo: just like in brson's pattern above
seanmonstar: its cause TcpStream is an odd duckling, and can be mutated through &self
jonhoo: mmm
seanmonstar: its safe to copy from a stream back onto itself
seanmonstar: so io::copy(&tcp, &tcp) works
jonhoo: oh, sure, I realize that, but for the builder pattern specifically it seems strange to not take &mut self even though *technically* you can
jonhoo: also, are you allowed to connect multiple times from the same builder?
jonhoo: because the current API allows that, right?
seanmonstar: nope, looks like it wil panic if tried again
jonhoo: yeah, I don't think the underlying sockets allows that
seanmonstar: i agree that the semantics of the api feel very not-normal
jonhoo: I guess *technically* the builder could allow that by lazily creating the socket on connect
jonhoo: which is the case for brson's example, and the reason his Command's build takes &self
jonhoo: but somehow it feels cleaner to me, especially for TcpBuilder, to take `self`
jonhoo: since there is just *one* socket that you're constructing
jonhoo: and then I think it follows that it should also be &mut
jonhoo: even though the syscall API allows &self
jonhoo: it'd be a pretty serious breaking change though
seanmonstar: would it though? the most common case is likely building it all at once
jonhoo: ah, you think most code actually conforms to the stricter api
jonhoo: yeah, probably
jonhoo: though it would require people to place `mut` in a couple of places if we made the methods `&mut self`
seanmonstar: i dunno, im sure you'd get push back if you did
seanmonstar: but i'd be silently rooting for you
jonhoo: haha, probably
jonhoo: thanks :p
arete: me too, I remember the API being pretty terrible =)
jonhoo: maybe I'll file a PR to revamp it and fix up the docs
jonhoo: worth filing an issue first to discuss you think?
sfackler: jonhoo: I would
sfackler: that builder is very old and barely used
sfackler: conventions around it are not super clear
sfackler: jonhoo: we moved a bunch of stuff from net2 into libstd a year or so ago, but left those builders out of it because we weren't super sure about the way they should work
jonhoo: sfackler: mmm, fair enough. okay, I'll file a ticket discussing this

Add UDP recvmmsg interface.

Linux, FreeBSD and maybe others have the recvmmsg call for receiving many messages from UDP socket at once. This could be a great feature for this library.

I think I could submit a PR for that, but It could be better if someone guided me a bit about where to better place this feature.

Support wasm32-wasi compile target

Compiling to wasm32-wasi on the stable rustc 1.39 fails, so it seems solution implemented in #84 is not working anymore.

Currently compilation fails:

   Compiling net2 v0.2.33 (https://github.com/rust-lang-nursery/net2-rs#eda403f0)
error[E0432]: unresolved import `libc::__wasi_fd_t`
  --> /Users/max/.cargo/git/checkouts/net2-rs-4b5319289a3d25c1/eda403f/src/sys/wasi/mod.rs:12:25
   |
12 | use libc::{self, c_int, __wasi_fd_t};
   |                         ^^^^^^^^^^^ no `__wasi_fd_t` in the root

error[E0432]: unresolved import `sys::c::__wasi_fd_t`
 --> /Users/max/.cargo/git/checkouts/net2-rs-4b5319289a3d25c1/eda403f/src/sys/wasi/impls.rs:5:17
  |
5 | use sys::{self, c::__wasi_fd_t};
  |                 ^^^^^^^^^^^^^^ no `__wasi_fd_t` in `sys::c`

There are now implementations of a networking in wasi which hopefully could be used to provide networking.

There are various dependent crates which would be great to compile to WASI, like async-rs/async-std#505

TcpBuilder::connect should use SocketAddr instead of ToSocketAddrs.

If ToSocketAddrs are resolved to multiple addresses, then in case of failure
connect will be used multiple times with the same socket. This is incorrect.
After first failed connect the state of socket is unspecified and socket should
not be reused.

Additionally, if socket is in non-blocking mode, then the connect can return
EINPROGRESS. Connection will not be aborted, and further calls to connect will
fail with EALREADY, because connection request is already in progress.

error: could not compile `net2`

🐛 Bug description

Describe your issue in detail.
execute wasm-pack build ,report error: could not compile net2.
🤔 Expected Behavior

What should have happened?
compile successful
👟 Steps to reproduce

Clear steps describing how to reproduce the issue, including commands and flags run. If you are seeing an error, please include the full error message and stack trace.

$ wasm-pack build > log.log
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling net2 v0.2.33
Compiling openssl-sys v0.9.53
Compiling http v0.1.21
Compiling string v0.2.1
Compiling tokio-buf v0.1.1
Compiling backtrace v0.3.40
Compiling mime_guess v2.0.1
Compiling cookie v0.12.0
error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\tcp.rs:18:5
|
18 | use sys::c;
| ^^^ maybe a missing crate sys?

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\udp.rs:18:5
|
18 | use sys::c;
| ^^^ maybe a missing crate sys?

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\socket.rs:22:5
|
22 | use sys;
| ^^^ no sys in the root

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\socket.rs:23:5
|
23 | use sys::c;
| ^^^ maybe a missing crate sys?

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:19:5
|
19 | use sys;
| ^^^ no sys in the root

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:20:5
|
20 | use sys::c;
| ^^^ maybe a missing crate sys?

error: failed to run custom build command for openssl-sys v0.9.53

Caused by:
process didn't exit successfully: D:\project\rust\wasm-pack-template\target\release\build\openssl-sys-b802ceacb66bf576\build-script-main (exit code: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_OPENSSL_LIB_DIR
WASM32_UNKNOWN_UNKNOWN_OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
OPENSSL_LIB_DIR unset
cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_OPENSSL_INCLUDE_DIR
WASM32_UNKNOWN_UNKNOWN_OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
OPENSSL_INCLUDE_DIR unset
cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_OPENSSL_DIR
WASM32_UNKNOWN_UNKNOWN_OPENSSL_DIR unset
cargo:rerun-if-env-changed=OPENSSL_DIR
OPENSSL_DIR unset
run pkg_config fail: "Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override"
note: vcpkg did not find openssl as libcrypto and libssl: the vcpkg-rs Vcpkg build helper can only find libraries built for the MSVC ABI.
note: vcpkg did not find openssl as ssleay32 and libeay32: the vcpkg-rs Vcpkg build helper can only find libraries built for the MSVC ABI.

--- stderr
thread 'main' panicked at '

Could not find directory of OpenSSL installation, and this -sys crate cannot
proceed without this knowledge. If OpenSSL is installed and this crate had
trouble finding it, you can set the OPENSSL_DIR environment variable for the
compilation process.

Make sure you also have the development packages of openssl installed.
For example, libssl-dev on Ubuntu or openssl-devel on Fedora.

If you're in a situation where you think the directory should be found
automatically, please open a bug at https://github.com/sfackler/rust-openssl
and include information about your system as well as this message.

$HOST = x86_64-pc-windows-msvc
$TARGET = wasm32-unknown-unknown
openssl-sys = 0.9.53

', D:\cargo\registry\src\github.com-1ecc6299db9ec823\openssl-sys-0.9.53\build\find_normal.rs:150:5
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\socket.rs:30:24
|
30 | pub fn new(family: c_int, ty: c_int) -> io::Result {
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
11 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\socket.rs:30:35
|
30 | pub fn new(family: c_int, ty: c_int) -> io::Result {
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
11 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\socket.rs:101:32
|
101 | match storage.ss_family as c_int {
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
11 | use std::os::raw::c_int;
|

error[E0412]: cannot find type Socket in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:62:31
|
62 | pub fn set_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int,
| ^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use socket::Socket;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:62:44
|
62 | pub fn set_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int,
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:62:56
|
62 | pub fn set_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int,
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_void in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:65:54
|
65 | let payload = &payload as *const T as *const c_void;
| ^^^^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
|
13 | use std::ffi::c_void;
|
13 | use std::os::raw::c_void;
|

error[E0425]: cannot find function setsockopt in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:68:20
|
68 | try!(::cvt(setsockopt(sock, opt, val, payload as *const _,
| ^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type socklen_t in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:69:54
|
69 | ... mem::size_of::() as socklen_t)));
| ^^^^^^^^^ not found in this scope

error[E0412]: cannot find type Socket in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:74:31
|
74 | pub fn get_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int) -> io::Result {
| ^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use socket::Socket;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:74:44
|
74 | pub fn get_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int) -> io::Result {
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:74:56
|
74 | pub fn get_opt<T: Copy>(sock: Socket, opt: c_int, val: c_int) -> io::Result {
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type socklen_t in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:77:46
|
77 | let mut len = mem::size_of::() as socklen_t;
| ^^^^^^^^^ not found in this scope

error[E0425]: cannot find function getsockopt in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:80:20
|
80 | try!(::cvt(getsockopt(sock, opt, val,
| ^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type Socket in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:641:26
|
641 | fn as_sock(&self) -> Socket;
| ^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use socket::Socket;
|

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:675:33
|
675 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF, size as c_int)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_RCVBUF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:675:45
|
675 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF, size as c_int)
| ^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:675:64
|
675 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF, size as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:679:33
|
679 | get_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF).map(int2usize)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_RCVBUF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:679:45
|
679 | get_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF).map(int2usize)
| ^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:683:33
|
683 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF, size as c_int)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_SNDBUF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:683:45
|
683 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF, size as c_int)
| ^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:683:64
|
683 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF, size as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:687:33
|
687 | get_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF).map(int2usize)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_SNDBUF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:687:45
|
687 | get_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF).map(int2usize)
| ^^^^^^^^^ not found in this scope

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:691:33
|
691 | set_opt(self.as_sock(), v(IPPROTO_TCP), TCP_NODELAY,
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_TCP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:691:35
|
691 | set_opt(self.as_sock(), v(IPPROTO_TCP), TCP_NODELAY,
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value TCP_NODELAY in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:691:49
|
691 | set_opt(self.as_sock(), v(IPPROTO_TCP), TCP_NODELAY,
| ^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:692:27
|
692 | nodelay as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:695:33
|
695 | get_opt(self.as_sock(), v(IPPROTO_TCP), TCP_NODELAY)
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_TCP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:695:35
|
695 | get_opt(self.as_sock(), v(IPPROTO_TCP), TCP_NODELAY)
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value TCP_NODELAY in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:695:49
|
695 | get_opt(self.as_sock(), v(IPPROTO_TCP), TCP_NODELAY)
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:802:33
|
802 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVTIMEO,
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_RCVTIMEO in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:802:45
|
802 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVTIMEO,
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function ms2timeout in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:803:16
|
803 | ms2timeout(dur))
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:807:33
|
807 | get_opt(self.as_sock(), SOL_SOCKET, SO_RCVTIMEO)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_RCVTIMEO in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:807:45
|
807 | get_opt(self.as_sock(), SOL_SOCKET, SO_RCVTIMEO)
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value timeout2ms in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:808:18
|
808 | .map(timeout2ms)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:812:33
|
812 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO,
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_SNDTIMEO in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:812:45
|
812 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO,
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function ms2timeout in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:813:16
|
813 | ms2timeout(dur))
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:817:33
|
817 | get_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_SNDTIMEO in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:817:45
|
817 | get_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO)
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value timeout2ms in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:818:18
|
818 | .map(timeout2ms)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:838:33
|
838 | set_opt(self.as_sock(), IPPROTO_IP, IP_TTL, ttl as c_int)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_TTL in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:838:45
|
838 | set_opt(self.as_sock(), IPPROTO_IP, IP_TTL, ttl as c_int)
| ^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:838:60
|
838 | set_opt(self.as_sock(), IPPROTO_IP, IP_TTL, ttl as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:842:19
|
842 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_TTL)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:842:42
|
842 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_TTL)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_TTL in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:842:54
|
842 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_TTL)
| ^^^^^^ not found in this scope

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:847:33
|
847 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:847:35
|
847 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_V6ONLY in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:847:50
|
847 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
| ^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:847:74
|
847 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:851:33
|
851 | get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY).map(int2bool)
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:851:35
|
851 | get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY).map(int2bool)
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_V6ONLY in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:851:50
|
851 | get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY).map(int2bool)
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:859:33
|
859 | get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_ERROR in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:859:45
|
859 | get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
| ^^^^^^^^ not found in this scope

error[E0425]: cannot find function set_nonblocking in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:863:9
|
863 | set_nonblocking(self.as_sock(), nonblocking)
| ^^^^^^^^^^^^^^^ help: try: self.set_nonblocking

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:867:33
|
867 | set_opt(self.as_sock(), SOL_SOCKET, SO_LINGER, dur2linger(dur))
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_LINGER in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:867:45
|
867 | set_opt(self.as_sock(), SOL_SOCKET, SO_LINGER, dur2linger(dur))
| ^^^^^^^^^ not found in this scope

error[E0425]: cannot find function dur2linger in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:867:56
|
867 | set_opt(self.as_sock(), SOL_SOCKET, SO_LINGER, dur2linger(dur))
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:871:33
|
871 | get_opt(self.as_sock(), SOL_SOCKET, SO_LINGER).map(linger2dur)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_LINGER in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:871:45
|
871 | get_opt(self.as_sock(), SOL_SOCKET, SO_LINGER).map(linger2dur)
| ^^^^^^^^^ not found in this scope

error[E0412]: cannot find type linger in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:910:27
|
910 | fn linger2dur(linger_opt: linger) -> Option {
| ^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:953:20
|
953 | pub fn int2bool(n: c_int) -> bool {
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:957:21
|
957 | pub fn int2usize(n: c_int) -> usize {
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:962:19
|
962 | pub fn int2err(n: c_int) -> Optionio::Error {
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:973:33
|
973 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF, size as c_int)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_RCVBUF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:973:45
|
973 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF, size as c_int)
| ^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:973:64
|
973 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF, size as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:977:33
|
977 | get_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF).map(int2usize)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_RCVBUF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:977:45
|
977 | get_opt(self.as_sock(), SOL_SOCKET, SO_RCVBUF).map(int2usize)
| ^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:981:33
|
981 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF, size as c_int)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_SNDBUF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:981:45
|
981 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF, size as c_int)
| ^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:981:64
|
981 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF, size as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:985:33
|
985 | get_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF).map(int2usize)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_SNDBUF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:985:45
|
985 | get_opt(self.as_sock(), SOL_SOCKET, SO_SNDBUF).map(int2usize)
| ^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:989:33
|
989 | set_opt(self.as_sock(), SOL_SOCKET, SO_BROADCAST,
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_BROADCAST in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:989:45
|
989 | set_opt(self.as_sock(), SOL_SOCKET, SO_BROADCAST,
| ^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:990:29
|
990 | broadcast as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:993:33
|
993 | get_opt(self.as_sock(), SOL_SOCKET, SO_BROADCAST)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_BROADCAST in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:993:45
|
993 | get_opt(self.as_sock(), SOL_SOCKET, SO_BROADCAST)
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:997:33
|
997 | set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_LOOP,
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_MULTICAST_LOOP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:997:45
|
997 | set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_LOOP,
| ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:998:37
|
998 | multicast_loop_v4 as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1001:33
|
1001 | get_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_LOOP)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_MULTICAST_LOOP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1001:45
|
1001 | get_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_LOOP)
| ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1006:33
|
1006 | set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_TTL,
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_MULTICAST_TTL in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1006:45
|
1006 | set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_TTL,
| ^^^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1007:36
|
1007 | multicast_ttl_v4 as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1011:19
|
1011 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_MULTICAST_TTL)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1011:42
|
1011 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_MULTICAST_TTL)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_MULTICAST_TTL in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1011:54
|
1011 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_MULTICAST_TTL)
| ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1019:33
|
1019 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS,
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1019:35
|
1019 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS,
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_MULTICAST_HOPS in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1019:50
|
1019 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS,
| ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1020:25
|
1020 | _hops as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1027:19
|
1027 | get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1027:42
|
1027 | get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS)
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1027:44
|
1027 | get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS)
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_MULTICAST_HOPS in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1027:59
|
1027 | get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS)
| ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1032:33
|
1032 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_LOOP,
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1032:35
|
1032 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_LOOP,
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_MULTICAST_LOOP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1032:50
|
1032 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_LOOP,
| ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1033:37
|
1033 | multicast_loop_v6 as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1036:33
|
1036 | get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_LOOP)
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1036:35
|
1036 | get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_LOOP)
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_MULTICAST_LOOP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1036:50
|
1036 | get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_LOOP)
| ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1044:33
|
1044 | set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF, ip2in_addr(_interface))
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_MULTICAST_IF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1044:45
|
1044 | set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF, ip2in_addr(_interface))
| ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function ip2in_addr in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1044:62
|
1044 | set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF, ip2in_addr(_interface))
| ^^^^^^^^^^ help: a function with a similar name exists: ip2in6_addr

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1051:33
|
1051 | get_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF).map(in_addr2ip)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_MULTICAST_IF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1051:45
|
1051 | get_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF).map(in_addr2ip)
| ^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1058:33
|
1058 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF, to_ipv6mr_interface(_interface))
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1058:35
|
1058 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF, to_ipv6mr_interface(_interface))
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_MULTICAST_IF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1058:50
|
1058 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF, to_ipv6mr_interface(_interface))
| ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1065:19
|
1065 | get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF).map(|b| b as u32)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1065:42
|
1065 | get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF).map(|b| b as u32)
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1065:44
|
1065 | get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF).map(|b| b as u32)
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_MULTICAST_IF in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1065:59
|
1065 | get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF).map(|b| b as u32)
| ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1069:33
|
1069 | set_opt(self.as_sock(), IPPROTO_IP, IP_TTL, ttl as c_int)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_TTL in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1069:45
|
1069 | set_opt(self.as_sock(), IPPROTO_IP, IP_TTL, ttl as c_int)
| ^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1069:60
|
1069 | set_opt(self.as_sock(), IPPROTO_IP, IP_TTL, ttl as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1073:19
|
1073 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_TTL)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1073:42
|
1073 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_TTL)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_TTL in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1073:54
|
1073 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IP_TTL)
| ^^^^^^ not found in this scope

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1081:33
|
1081 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_UNICAST_HOPS, _ttl as c_int)
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1081:35
|
1081 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_UNICAST_HOPS, _ttl as c_int)
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_UNICAST_HOPS in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1081:50
|
1081 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_UNICAST_HOPS, _ttl as c_int)
| ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1081:77
|
1081 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_UNICAST_HOPS, _ttl as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1088:19
|
1088 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IPV6_UNICAST_HOPS)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1088:42
|
1088 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IPV6_UNICAST_HOPS)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_UNICAST_HOPS in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1088:54
|
1088 | get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IPV6_UNICAST_HOPS)
| ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1093:33
|
1093 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1093:35
|
1093 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_V6ONLY in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1093:50
|
1093 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
| ^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type c_int in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1093:74
|
1093 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
| ^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_int;
|

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1097:33
|
1097 | get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY).map(int2bool)
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1097:35
|
1097 | get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY).map(int2bool)
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_V6ONLY in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1097:50
|
1097 | get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY).map(int2bool)
| ^^^^^^^^^^^ not found in this scope

error[E0422]: cannot find struct, variant or union type ip_mreq in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1102:20
|
1102 | let mreq = ip_mreq {
| ^^^^^^^ not found in this scope

error[E0425]: cannot find function ip2in_addr in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1103:28
|
1103 | imr_multiaddr: ip2in_addr(multiaddr),
| ^^^^^^^^^^ help: a function with a similar name exists: ip2in6_addr

error[E0425]: cannot find function ip2in_addr in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1104:28
|
1104 | imr_interface: ip2in_addr(interface),
| ^^^^^^^^^^ help: a function with a similar name exists: ip2in6_addr

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1106:33
|
1106 | set_opt(self.as_sock(), IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_ADD_MEMBERSHIP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1106:45
|
1106 | set_opt(self.as_sock(), IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq)
| ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0422]: cannot find struct, variant or union type ipv6_mreq in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1111:20
|
1111 | let mreq = ipv6_mreq {
| ^^^^^^^^^ not found in this scope

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1115:33
|
1115 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_ADD_MEMBERSHIP,
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1115:35
|
1115 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_ADD_MEMBERSHIP,
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_ADD_MEMBERSHIP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1115:50
|
1115 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_ADD_MEMBERSHIP,
| ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0422]: cannot find struct, variant or union type ip_mreq in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1121:20
|
1121 | let mreq = ip_mreq {
| ^^^^^^^ not found in this scope

error[E0425]: cannot find function ip2in_addr in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1122:28
|
1122 | imr_multiaddr: ip2in_addr(multiaddr),
| ^^^^^^^^^^ help: a function with a similar name exists: ip2in6_addr

error[E0425]: cannot find function ip2in_addr in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1123:28
|
1123 | imr_interface: ip2in_addr(interface),
| ^^^^^^^^^^ help: a function with a similar name exists: ip2in6_addr

error[E0425]: cannot find value IPPROTO_IP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1125:33
|
1125 | set_opt(self.as_sock(), IPPROTO_IP, IP_DROP_MEMBERSHIP, mreq)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IP_DROP_MEMBERSHIP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1125:45
|
1125 | set_opt(self.as_sock(), IPPROTO_IP, IP_DROP_MEMBERSHIP, mreq)
| ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0422]: cannot find struct, variant or union type ipv6_mreq in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1130:20
|
1130 | let mreq = ipv6_mreq {
| ^^^^^^^^^ not found in this scope

error[E0425]: cannot find function v in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1134:33
|
1134 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_DROP_MEMBERSHIP,
| ^ not found in this scope

error[E0425]: cannot find value IPPROTO_IPV6 in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1134:35
|
1134 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_DROP_MEMBERSHIP,
| ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value IPV6_DROP_MEMBERSHIP in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1134:50
|
1134 | set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_DROP_MEMBERSHIP,
| ^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1139:33
|
1139 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVTIMEO,
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_RCVTIMEO in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1139:45
|
1139 | set_opt(self.as_sock(), SOL_SOCKET, SO_RCVTIMEO,
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function ms2timeout in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1140:16
|
1140 | ms2timeout(dur))
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1144:33
|
1144 | get_opt(self.as_sock(), SOL_SOCKET, SO_RCVTIMEO)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_RCVTIMEO in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1144:45
|
1144 | get_opt(self.as_sock(), SOL_SOCKET, SO_RCVTIMEO)
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value timeout2ms in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1145:18
|
1145 | .map(timeout2ms)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1149:33
|
1149 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO,
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_SNDTIMEO in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1149:45
|
1149 | set_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO,
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function ms2timeout in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1150:16
|
1150 | ms2timeout(dur))
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1154:33
|
1154 | get_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_SNDTIMEO in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1154:45
|
1154 | get_opt(self.as_sock(), SOL_SOCKET, SO_SNDTIMEO)
| ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value timeout2ms in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1155:18
|
1155 | .map(timeout2ms)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SOL_SOCKET in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1175:33
|
1175 | get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
| ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value SO_ERROR in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1175:45
|
1175 | get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
| ^^^^^^^^ not found in this scope

error[E0425]: cannot find function set_nonblocking in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1233:9
|
1233 | set_nonblocking(self.as_sock(), nonblocking)
| ^^^^^^^^^^^^^^^ help: try: self.set_nonblocking

error[E0412]: cannot find type Socket in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1237:39
|
1237 | fn do_connect<A: ToSocketAddrs>(sock: Socket, addr: A) -> io::Result<()> {
| ^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use socket::Socket;
|

error[E0412]: cannot find type in_addr in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1318:20
|
1318 | fn in_addr2ip(ip: &in_addr) -> Ipv4Addr {
| ^^^^^^^ not found in this scope

error[E0412]: cannot find type c_uint in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1335:39
|
1335 | fn to_ipv6mr_interface(value: u32) -> c_uint {
| ^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_uint;
error[E0599]: no method named as_sock found for type &udp::UdpBuilder in the current scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1499:22
|
1499 | get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
| ^^^^^^^ method not found in &udp::UdpBuilder
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item as_sock, perhaps you need to implement it:
candidate #1: ext::AsSock

error: aborting due to 317 previous errors

Some errors have detailed explanations: E0046, E0412, E0422, E0425, E0432, E0599.
For more information about an error, try rustc --explain E0046.
error: could not compile net2.
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute cargo build: exited with exit code: 101

🌍 Your environment

Include the relevant details of your environment.
wasm-pack version: wasm-pack 0.8.1
rustc version: rustc 1.39.0 (4560ea788 2019-11-04)
operation system: windows10

Can't compile package to wasm

Hi,
Getting error while compiling package to webassembly using wasm32-unknown-uknown

cargo build --target wasm32-unknown-unknown
   Compiling net2 v0.2.33
   Compiling byteorder v1.3.2
   Compiling arrayvec v0.4.11
   Compiling rand v0.5.6
   Compiling log v0.4.8
   Compiling openssl-sys v0.9.48
   Compiling tokio-executor v0.1.8
   Compiling crunchy v0.2.2
error[E0432]: unresolved import `sys`
  --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/tcp.rs:18:5
   |
18 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?

error[E0432]: unresolved import `sys`
  --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/udp.rs:18:5
   |
18 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?

   Compiling bitflags v1.1.0
error[E0432]: unresolved import `sys`
  --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/socket.rs:22:5
   |
22 | use sys;
   |     ^^^ no `sys` in the root

error[E0432]: unresolved import `sys`
  --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/socket.rs:23:5
   |
23 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?

error[E0432]: unresolved import `sys`
  --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:19:5
   |
19 | use sys;
   |     ^^^ no `sys` in the root

error[E0432]: unresolved import `sys`
  --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:20:5
   |
20 | use sys::c;
   |     ^^^ maybe a missing `extern crate sys;`?

error: failed to run custom build command for `openssl-sys v0.9.48`
 --------
error[E0599]: no method named `as_sock` found for type `&tcp::TcpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1428:22
     |
1428 |         set_opt(self.as_sock(), SOL_SOCKET, SO_REUSEADDR,
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error[E0599]: no method named `as_sock` found for type `&tcp::TcpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1434:22
     |
1434 |         get_opt(self.as_sock(), SOL_SOCKET, SO_REUSEADDR).map(int2bool)
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error[E0599]: no method named `as_sock` found for type `&tcp::TcpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1443:22
     |
1443 |         get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error[E0599]: no method named `as_sock` found for type `&tcp::TcpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1448:22
     |
1448 |         set_opt(self.as_sock(), SOL_SOCKET, SO_LINGER, dur2linger(dur))
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error[E0599]: no method named `as_sock` found for type `&tcp::TcpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1453:22
     |
1453 |         get_opt(self.as_sock(), SOL_SOCKET, SO_LINGER).map(linger2dur)
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error[E0599]: no method named `as_sock` found for type `&udp::UdpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1464:22
     |
1464 |         set_opt(self.as_sock(), IPPROTO_IP, IP_TTL, ttl as c_int)
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error[E0599]: no method named `as_sock` found for type `&udp::UdpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1474:22
     |
1474 |         set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY, only_v6 as c_int)
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error[E0599]: no method named `as_sock` found for type `&udp::UdpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1484:22
     |
1484 |         set_opt(self.as_sock(), SOL_SOCKET, SO_REUSEADDR,
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error[E0599]: no method named `as_sock` found for type `&udp::UdpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1490:22
     |
1490 |         get_opt(self.as_sock(), SOL_SOCKET, SO_REUSEADDR).map(int2bool)
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error[E0599]: no method named `as_sock` found for type `&udp::UdpBuilder` in the current scope
    --> /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.33/src/ext.rs:1499:22
     |
1499 |         get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
     |                      ^^^^^^^
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `as_sock`, perhaps you need to implement it:
             candidate #1: `ext::AsSock`

error: aborting due to 317 previous errors

Some errors have detailed explanations: E0046, E0412, E0422, E0425, E0432, E0599.
For more information about an error, try `rustc --explain E0046`.
error: Could not compile `net2`.
warning: build failed, waiting for other jobs to finish...
error: build failed

How can I solve this error? @alexcrichton can you help me on this
TIA

accept() on ipv6 socket fails

Originally reported in https://github.com/dpc/mioco/issues/116 .

I reduced to:

#[macro_use]
extern crate log;
extern crate env_logger;
extern crate net2;

use std::{net,str};

const DEFAULT_LISTEN_ADDR : &'static str = "::1";
fn listend_addr() -> net::IpAddr {
    str::FromStr::from_str(DEFAULT_LISTEN_ADDR).unwrap()
}

fn main() {
    env_logger::init().unwrap();
    info!("Starting...");

    let addr = listend_addr();
    let builder = net2::TcpBuilder::new_v6().unwrap();
    builder.only_v6(true).unwrap();
    let addr = net::SocketAddr::new(addr.clone(), 0);
    builder.bind(&addr).unwrap();
    let listener = builder.to_tcp_listener().unwrap();
    info!("Listening on {:?}", listener.local_addr());

    let _ = listener.accept().unwrap();
    info!("Stopped.");
}

panicking on accept().unwrap() with:

thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 22, message: "Invalid argument" } }', ../src/libcore/result.rs:746

with strace reporting:

socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
ioctl(3, FIOCLEX)                       = 0
setsockopt(3, SOL_IPV6, IPV6_V6ONLY, [1], 4) = 0
bind(3, {sa_family=AF_INET6, sin6_port=htons(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
futex(0x7f2d749880c8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
accept4(3, 0x7ffcd0e43b20, 0x7ffcd0e43b1c, SOCK_CLOEXEC) = -1 EINVAL (Invalid argument)

Build fails for x86_64-linux-android

https://travis-ci.org/rust-lang-nursery/rustup.rs/jobs/261063687#L1537

error[E0308]: mismatched types
  --> target/cargo-home/registry/src/github.com-1ecc6299db9ec823/net2-0.2.30/src/socket.rs:40:51
   |
40 |             ::cvt(c::bind(self.inner.raw(), addr, len as len_t)).map(|_| ())
   |                                                   ^^^^^^^^^^^^ expected i32, found u32

I assume the fix is just to

-#[cfg(all(target_arch = "aarch64",target_os = "android"))]
+#[cfg(all(any(target_arch = "aarch64", target_arch = "x86_64"),target_os = "android"))]
use libc::c_int as len_t;

I'll see if that works locally.

Android termux aarch64 error

Try build webrender on android termux aarch64, get this error:

cargo build --lib
   Compiling net2 v0.2.32
   Compiling unicode-bidi v0.3.4
   Compiling num-iter v0.1.37
   Compiling block-padding v0.1.2
   Compiling num-derive v0.2.3
   Compiling rand_os v0.1.3
   Compiling num-rational v0.2.1
   Compiling inflate v0.4.2
   Compiling deflate v0.7.18
error[E0308]: mismatched types
  --> /data/data/com.termux/files/home/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/socket.rs:40:51
   |
40 |             ::cvt(c::bind(self.inner.raw(), addr, len as len_t)).map(|_| ())
   |                                                   ^^^^^^^^^^^^ expected u32, found i32

   Compiling base64 v0.10.0
   Compiling fxhash v0.2.1
error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: Could not compile `net2`.
warning: build failed, waiting for other jobs to finish...
error: build failed

No need to incite segregation between IPv4 and IPv6

C programmers have been advised to use getaddrinfo(3) for nearly two decades by which their program can be protocol-agnostic. Rust API shouldn't try to go back in time to the days when it was not available.

Of course you can give hints to getaddrinfo(3) in order to opt-out from IPv6 connections if you're not a great fan of IPv6 (like I'm not.)

In fact the same goes for TCP vs UDP in principle.

Add read_timeout support for UDP sockets

I was hoping to get this with the socket opts in the std::net, but that looks to have been deprecated in favor of this library. Do you have plans to add additional socket_opts for UDP?

Add `local_addr` method to TcpBuilder

I've got a TcpBuilder which is bound and I'd like to get it's local address. I don't see why this type shouldn't support the local_addr method the same as TcpListener and TcpStream do.

Build failed on target `mipsel-unknown-linux-uclibc`

My configs

Cargo.toml

[dependencies]
socket2 = "0.3.11"
net2 = "0.2.33"

[profile.dev]
panic = "abort"

[profile.release]
panic = "abort"

~/.cargo/config

[build]
target = "mipsel-unknown-linux-uclibc"

[target.mipsel-unknown-linux-uclibc]
linker = "mipsel-openwrt-linux-gcc"

Xargo.toml

[target.mipsel-unknown-linux-uclibc.dependencies.std]
features = []

Build error.

$ xargo build --target mipsel-unknown-linux-uclibc --release
   Compiling net2 v0.2.33
   Compiling socket2 v0.3.11
error[E0425]: cannot find value `IPV6_MULTICAST_HOPS` in this scope
    --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:1019:50
     |
1019 |         set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS,
     |                                                  ^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_MULTICAST_LOOP`

error[E0425]: cannot find value `IPV6_MULTICAST_HOPS` in this scope
    --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:1027:59
     |
1027 |         get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_HOPS)
     |                                                           ^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_MULTICAST_LOOP`

error[E0425]: cannot find value `IP_MULTICAST_IF` in this scope
    --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:1044:45
     |
1044 |         set_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF, ip2in_addr(_interface))
     |                                             ^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IP_MULTICAST_TTL`

error[E0425]: cannot find value `IP_MULTICAST_IF` in this scope
    --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:1051:45
     |
1051 |         get_opt(self.as_sock(), IPPROTO_IP, IP_MULTICAST_IF).map(in_addr2ip)
     |                                             ^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IP_MULTICAST_TTL`

error[E0425]: cannot find value `IPV6_MULTICAST_IF` in this scope
    --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:1058:50
     |
1058 |         set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF, to_ipv6mr_interface(_interface))
     |                                                  ^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_MULTICAST_LOOP`

error[E0425]: cannot find value `IPV6_MULTICAST_IF` in this scope
    --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:1065:59
     |
1065 |         get_opt::<c_int>(self.as_sock(), v(IPPROTO_IPV6), IPV6_MULTICAST_IF).map(|b| b as u32)
     |                                                           ^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_MULTICAST_LOOP`

error[E0425]: cannot find value `IPV6_UNICAST_HOPS` in this scope
    --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:1081:50
     |
1081 |         set_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_UNICAST_HOPS, _ttl as c_int)
     |                                                  ^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `IPV6_UNICAST_HOPS` in this scope
    --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/net2-0.2.33/src/ext.rs:1088:54
     |
1088 |         get_opt::<c_int>(self.as_sock(), IPPROTO_IP, IPV6_UNICAST_HOPS)
     |                                                      ^^^^^^^^^^^^^^^^^ not found in this scope

error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0425`.
error: Could not compile `net2`.
warning: build failed, waiting for other jobs to finish...
error[E0425]: cannot find value `IPV6_UNICAST_HOPS` in crate `libc`
   --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.3.11/src/sys/unix.rs:446:72
    |
446 |             let raw: c_int = self.getsockopt(libc::IPPROTO_IPV6, libc::IPV6_UNICAST_HOPS)?;
    |                                                                        ^^^^^^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `IPV6_UNICAST_HOPS` in crate `libc`
   --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.3.11/src/sys/unix.rs:455:23
    |
455 |                 libc::IPV6_UNICAST_HOPS,
    |                       ^^^^^^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `IPV6_MULTICAST_HOPS` in crate `libc`
   --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.3.11/src/sys/unix.rs:554:72
    |
554 |             let raw: c_int = self.getsockopt(libc::IPPROTO_IPV6, libc::IPV6_MULTICAST_HOPS)?;
    |                                                                        ^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_MULTICAST_LOOP`

error[E0425]: cannot find value `IPV6_MULTICAST_HOPS` in crate `libc`
   --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.3.11/src/sys/unix.rs:560:60
    |
560 |         unsafe { self.setsockopt(libc::IPPROTO_IPV6, libc::IPV6_MULTICAST_HOPS, hops as c_int) }
    |                                                            ^^^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_MULTICAST_LOOP`

error[E0425]: cannot find value `IP_MULTICAST_IF` in crate `libc`
   --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.3.11/src/sys/unix.rs:566:57
    |
566 |                 self.getsockopt(libc::IPPROTO_IP, libc::IP_MULTICAST_IF)?;
    |                                                         ^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IP_MULTICAST_TTL`

error[E0425]: cannot find value `IP_MULTICAST_IF` in crate `libc`
   --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.3.11/src/sys/unix.rs:575:58
    |
575 |         unsafe { self.setsockopt(libc::IPPROTO_IP, libc::IP_MULTICAST_IF, imr_interface) }
    |                                                          ^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IP_MULTICAST_TTL`

error[E0425]: cannot find value `IPV6_MULTICAST_IF` in crate `libc`
   --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.3.11/src/sys/unix.rs:580:72
    |
580 |             let raw: c_int = self.getsockopt(libc::IPPROTO_IPV6, libc::IPV6_MULTICAST_IF)?;
    |                                                                        ^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_MULTICAST_LOOP`

error[E0425]: cannot find value `IPV6_MULTICAST_IF` in crate `libc`
   --> /root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/socket2-0.3.11/src/sys/unix.rs:589:23
    |
589 |                 libc::IPV6_MULTICAST_IF,
    |                       ^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `IPV6_MULTICAST_LOOP`

error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0425`.
error: Could not compile `socket2`.

To learn more, run the command again with --verbose.

Anyone can help me ?

"nightly" feature no longer requires a nightly

Might want to set it as a default feature?

If not, it'd be nice to mention in the docs which methods require it - I spent a while trying to figure out why I couldn't call set_read_timeout.

build fails on SmartOS/Solaris

This happened via tokio, but I suspect there's just some cfg here not being set correctly for x86_64-sun-solaris.

   Compiling tokio-tls v0.1.4
error[E0432]: unresolved import `net2::unix`
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-proto-0.1.1/src/tcp_server.rs:222:15
    |
222 |     use net2::unix::*;
    |               ^^^^ Could not find `unix` in `net2`

Missing FromRawSocket

The documentation for TcpBuilder::new_* suggests there is a FromRawSocket trait. It does exist, but it's not exported. Is this a missing export or a documentation bug?

Support for ICMP sockets

I went through the RFC related to net2 and I didn't see any mention of ICMP support.
Both Linux [1] and MacOS support unprivileged sockets, with which an application could send
ICMP echo requests without being root.

I'm working on a tool that needs to send ICMP pings, and since I'll be writing some abstractions on top
of libc's stuff, I thought I might as well contribute back.

Would this be interesting for net2?

I do have the use-case, but maybe there's not enough demand for ICMP to justify adding it here.

[1] https://lwn.net/Articles/422330/

mismatched types error for x86_64-linux-android target

On travis, when building my project for x86_64-linux-android target, I got this error message:

Compiling net2 v0.2.32
error[E0308]: mismatched types
  --> /cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/socket.rs:40:51
   |
40 |             ::cvt(c::bind(self.inner.raw(), addr, len as len_t)).map(|_| ())
   |                                                   ^^^^^^^^^^^^ expected u32, found i32

Cant build with target aarch64-linux-android

On MacOS 10.12.4
rustup 1.2.0 (70faf07 2017-04-08)
rustc 1.16.0 (30cf806ef 2017-03-10)

when cargo build --target=aarch64-linux-android got error:

build with aarch64-linux-android
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading libc v0.2.22
   Compiling cfg-if v0.1.0
   Compiling libc v0.2.22
   Compiling net2 v0.2.27 (file:///Users/user/ws/net2-rs)
error[E0308]: mismatched types
  --> src/socket.rs:35:51
   |
35 |             ::cvt(c::bind(self.inner.raw(), addr, len)).map(|_| ())
   |                                                   ^^^ expected i32, found u32

error: aborting due to previous error

error: Could not compile `net2`.

To learn more, run the command again with --verbose.

TcpBuilder not calling WSAStartup in Windows

In Windows, the following code fails with the message Either the application has not called WSAStartup, or WSAStartup failed. Notice that using net::TCPListener works as expected. Adding a dummy TcpStream::connect before calling start_server also fixes that problem (although fails for another reason, still debugging).

extern crate net2;
use net2::TcpBuilder;

use std::net::TcpStream;
// use std::net::TcpListener;
use std::io::{Write, Read};
use std::thread;

fn start_server() {
    let listener = TcpBuilder::new_v4().unwrap().bind("127.0.0.1:16379").unwrap().listen(200).unwrap();
    // let listener = TcpListener::bind("127.0.0.1:16379").unwrap();

    for stream in listener.incoming() {
        match stream {
            Ok(mut stream) => {
                thread::spawn(move|| {
                    // connection succeeded
                    let mut v = [0u8; 512];
                    println!("handling client {:?}", stream.read(&mut v));
                });
            }
            Err(e) => { println!("error {:?}", e); }
        }
    }
    // close the socket server
    drop(listener);
}

fn start_client() {
    let mut stream = TcpStream::connect("127.0.0.1:16379").unwrap();
    let _ = stream.write(&[1,2,3]);
}

#[test]
fn t() {
    thread::spawn(|| start_server());
    thread::sleep_ms(1000);
    start_client();
    thread::sleep_ms(1000);
}

Set `SO_REUSEADDR` same as stdlib's net

Currently Rust's stdlib net module sets SO_REUSEADDR for a TcpListener on bind:
https://github.com/rust-lang/rust/blob/ddc28298b9133e6a9cc39e276f9feff51d808949/src/libstd/sys/common/net.rs#L325-L328

net2 does not.
I'm not sure whether this should come as a configuration option in the builder, as proposed in the RFC, or as the default for sockets (atleast for not-Windows systems) like Rust does.

(Edit: Also, I guess SO_REUSEADDR is not used on Windows because it has a slightly different meaning there)

Move Repository To rust-lang

Hello, the current rust-lang-nursery organisation is considered deprecated, and the Rust Programming Language organisation is trying to consolidate managing Rust's GitHub organisations, as such we'd like you to consider moving your repository to the main rust-lang organisation instead.

How Do I Move To rust-lang?

You most likely won't be able to transfer your repository directly, if so you'll need to transfer your repository to @Mark-Simulacrum, who will then move your repository to the rust-lang organisation.

Deprecating

If you no longer intend to maintain this repository, please let us know and we will take of deprecating the project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.