Skip to content

Conversation

frewsxcv
Copy link
Member

Closes #44050.

@rust-highfive
Copy link
Contributor

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 22, 2017
@frewsxcv
Copy link
Member Author

@sfackler one more here when you have a moment

@@ -721,16 +721,44 @@ impl UdpSocket {

/// Moves this UDP socket into or out of nonblocking mode.
///
/// On Unix this corresponds to calling fcntl, and on Windows this
/// corresponds to calling ioctlsocket.
/// This will result in `recv` and `send` operations/ becoming nonblocking,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray /

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also send_to/recv_from

/// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
/// socket.set_nonblocking(true).expect("set_nonblocking call failed");
/// let socket = UdpSocket::bind("127.0.0.1:7878").unwrap();
/// socket.connect("127.0.0.1:7879").unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be simpler to not connect and use send_to/recv_from instead?

/// // wait until network socket is ready, typically implemented
/// // via platform-specific APIs such as epoll or IOCP
/// wait_for_fd();
/// continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this continue.

@frewsxcv
Copy link
Member Author

@sfackler thanks for the review! comments addressed in the latest commit

/// Err(e) => panic!("encountered IO error: {}", e),
/// }
/// };
/// println!("bytes: {:?}", &buf[..num_bytes_read]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is failing. Note that .recv_from returns a Result<(usize, SocketAddr)>, not Result<usize>.

[01:04:03] ---- net/udp.rs - net::udp::UdpSocket::set_nonblocking (line 742) stdout ----
[01:04:03] 	error[E0277]: the trait bound `std::ops::RangeTo<(usize, std::net::SocketAddr)>: std::slice::SliceIndex<[u8]>` is not satisfied
[01:04:03]   --> net/udp.rs:23:26
[01:04:03]    |
[01:04:03] 23 | println!("bytes: {:?}", &buf[..num_bytes_read]);
[01:04:03]    |                          ^^^^^^^^^^^^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize`
[01:04:03]    |
[01:04:03]    = help: the trait `std::slice::SliceIndex<[u8]>` is not implemented for `std::ops::RangeTo<(usize, std::net::SocketAddr)>`
[01:04:03]    = note: required because of the requirements on the impl of `std::ops::Index<std::ops::RangeTo<(usize, std::net::SocketAddr)>>` for `[u8]`
[01:04:03] 
[01:04:03] thread 'rustc' panicked at 'couldn't compile the test', /checkout/src/librustdoc/test.rs:287:12
[01:04:03] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:04:03] 
[01:04:03] 
[01:04:03] failures:
[01:04:03]     net/udp.rs - net::udp::UdpSocket::set_nonblocking (line 742)
[01:04:03] 
[01:04:03] test result: FAILED. 876 passed; 1 failed; 10 ignored; 0 measured; 0 filtered out

@frewsxcv frewsxcv force-pushed the frewsxcv-udp-nonblocking branch from 15d8c28 to 04f27f0 Compare October 26, 2017 14:06
@frewsxcv
Copy link
Member Author

ci passes now

@sfackler
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Oct 27, 2017

📌 Commit 04f27f0 has been approved by sfackler

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 27, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Oct 28, 2017
…r=sfackler

Improve docs for UdpSocket::set_nonblocking.

Closes rust-lang#44050.
kennytm added a commit to kennytm/rust that referenced this pull request Oct 28, 2017
…r=sfackler

Improve docs for UdpSocket::set_nonblocking.

Closes rust-lang#44050.
bors added a commit that referenced this pull request Oct 28, 2017
Rollup of 7 pull requests

- Successful merges: #45421, #45449, #45505, #45535, #45549, #45574, #45585
- Failed merges:
@bors bors merged commit 04f27f0 into rust-lang:master Oct 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants