Skip to content

Commit

Permalink
Auto merge of #105394 - Patiga:improve-udpsocket-docs, r=workingjubilee
Browse files Browse the repository at this point in the history
Improve UdpSocket documentation

I tried working with `UdpSocket` and ran into `EINVAL` errors with no clear indication of what causes the error. Also, it was uncharacteristically hard to figure this module out, compared to other Rust `std` modules.

1. `send` and `send_to` return a `usize` This one is just clarity. Usually, returned `usize`s indicate that the buffer might have only been sent partially. This is not the case with UDP. Since that `usize` must always be `buffer.len()`, I have documented that.

2. `bind` limits `connect` and `send_to` When you bind to a limited address space like localhost, you can only `connect` to addresses in that same address space. Error kind: `AddrNotAvailable`.

3. `connect`ing to localhost locks you to localhost On Linux, if you first `connect` to localhost, subsequent `connect`s to
non-localhost addresses fail. Error kind: `InvalidInput`.

For debugging the third one, it was really hard to find someone else who already had that problem. I only managed to find this thread: https://www.mail-archive.com/[email protected]/msg159519.html
  • Loading branch information
bors committed Oct 3, 2023
2 parents 1b3c7f1 + ef2c5ee commit cc70c81
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit cc70c81

Please sign in to comment.