Skip to content

Use socket2::Socket for TcpStream #1442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

Thomasdezeeuw
Copy link
Collaborator

This includes a single breaking change TcpStream::peek now now accepts
an uninitialised buffer ([MaybeUninit]), rather than an initialised
one.

This also add TcpStream::recv which is the same as the io::Read::read
implementation, but accept an unitialised buffer.

Depends on #1431.

This includes a single breaking change which involves multiple UdpSocket
methods: the receive methods now accept an uninitialised buffer
([MaybeUninit<u8>]), rather than an initialised one. This is the case of
the following methods:

* UdpSocket::recv_from
* UdpSocket::peek_from
* UdpSocket::recv
* UdpSocket::peek

This allows higher level libraries, such as Tokio or Heph, to use
uninitialised buffers if they want to. Note that the API guarantees not
to write any uninitialised data to the buffer, so it's not unsound to
pass `&[u8]` to the methods.

Finally this adds a debug assertions to UdpSocket::recv_from that checks
if the buffer passed isn't zero sized. Passing a zero sized buffer to
recv_from causes the OS to not initialise the source address (at least
on macOS), which in turn causes a misleading error to be returned saying
the address family is invalid. Before this change didn't check this and
likely returned an invalid IPv6 address.
This includes a single breaking change TcpStream::peek now now accepts
an uninitialised buffer ([MaybeUninit<u8>]), rather than an initialised
one.

This also add TcpStream::recv which is the same as the io::Read::read
implementation, but accept an unitialised buffer.
@Thomasdezeeuw
Copy link
Collaborator Author

We're not adding socket2 as Mio dependency.

@Thomasdezeeuw Thomasdezeeuw deleted the issue_1381_v0.8_use-socket2-tcp_stream branch September 28, 2021 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant