FreeBSD 12 adds some new private fields to struct kevent, and it changes
the type of "data" from intptr_t to i64. For now libc only binds the
11-compat ABI, but that will change some day. Adjust mio's structure
definitions for compatibility with either ABI.
This should work on all 32 and 64 bit platforms.
Per the Linux manual:
> EAGAIN For nonblocking UNIX domain sockets, the socket is
> nonblocking, and the connection cannot be completed
> immediately.
Previously the code incorrectly assumed that the connection was now in
progress, which is incorrect. If that were the case EINPROGRESS
would/should be returned by the OS
This updates miow to 0.4, which now uses the windows-sys crate instead
of winapi, as the former is maintained and updated frequently as opposed
to winapi. The windows-sys crate also covers more of the Windows API
surface, which also allowed me to remove the dependency on ntapi (as it
still depends on winapi). There was only a single function,
`NtCancelIoFileEx` that was present in ntapi but not windows-sys, so I
merely added the extern declaration in the one place it was used as it
is not worth bringing in a dependency just for that.
This execute a user defined I/O closure while updating Mio's internal
state ensuring that the I/O receives more events if it hits a WouldBlock
error.
This is added to the following types:
* TcpStream
* UdpSocket
* UnixDatagram
* UnixStream
* unix::pipe::Sender
* unix::pipe::Receiver
Use the `LISTEN_FDS` mechanism to use pre-opened sockets.
Especially for `wasm32-wasi` there is no other way to get access to sockets,
than to use pre-opened sockets.
Because `wasm32-wasi` does not yet return `TcpListener::local_addr()`, an
unspecified IP address and port will be returned and displayed.
```
$ cargo +nightly build --target wasm32-wasi --release --example tcp_listenfd_server --features="os-poll net"
Compiling cfg-if v1.0.0
Compiling wasi v0.10.2+wasi-snapshot-preview1
Compiling log v0.4.14
Compiling libc v0.2.112
Compiling ppv-lite86 v0.2.15
Compiling wasi v0.11.0+wasi-snapshot-preview1
Compiling getrandom v0.2.3
Compiling rand_core v0.6.3
Compiling env_logger v0.8.4
Compiling rand_chacha v0.3.1
Compiling mio v0.8.0 (/home/harald/git/mio)
Compiling rand v0.8.4
Finished release [optimized] target(s) in 2.92s
$ wasmtime run --tcplisten 127.0.0.1:9000 --env 'LISTEN_FDS=1' target/wasm32-wasi/release/examples/tcp_listenfd_server.wasm
Using preopened socket FD 3
You can connect to the server using `nc`:
$ nc <IP> <PORT>
You'll see our welcome message and anything you type will be printed here.
```
Signed-off-by: Harald Hoyer <harald@profian.com>
Make the documentation a bit nicer. Usually the creation methods, such
as new, are the first methods in the first impl block, so that is where
people look for them.