Modern alternatives to net2?

net2 by alex crichton allows us to customize TCP sockets or UDP sockets as such:

TcpStream::from(TcpBuilder::new_v4()?.bind(metadata.local_socket)?.reuse_port(true)?.connect(metadata.remote_socket?)?)

However, it does not compile and uses rust from the bronze ages. Is there a postmodern alternative to net2?

(async?)

@alexcrichton, I just managed to get it to compile in linux. I am now working on the windows version. I had to update the version to 2018, and am updating the code. My oh my, you've come a long ways since the days of net2!

@alexcrichton GitHub - tbraun96/net2-rs: Extensions for standard networking types

I fixed compile errors on both windows and linux, but the others are unchecked

2 Likes

under socket2::Protocol - Rust , it's asking for an i32 input to form the protocol. IS there a table that shows what value maps to which protocol?

Those would be in the libc headers, but there are constructors for the common protocols.

ths IANA list for internet protocols is here , though, it's rare to pass a non-zero protocol to the socket contructor, as for most socket domain/type combos there's only one common choice (SOCK_RAW is a notable exeption).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.