Skip to content

Rename recvfrom -> recv_from, sendto -> send_to. #15265

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libnative/io/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ impl rtio::RtioSocket for UdpSocket {
#[cfg(unix)] type msglen_t = libc::size_t;

impl rtio::RtioUdpSocket for UdpSocket {
fn recvfrom(&mut self, buf: &mut [u8]) -> IoResult<(uint, rtio::SocketAddr)> {
fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(uint, rtio::SocketAddr)> {
let fd = self.fd();
let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() };
let storagep = &mut storage as *mut _ as *mut libc::sockaddr;
Expand All @@ -652,7 +652,7 @@ impl rtio::RtioUdpSocket for UdpSocket {
})
}

fn sendto(&mut self, buf: &[u8], dst: rtio::SocketAddr) -> IoResult<()> {
fn send_to(&mut self, buf: &[u8], dst: rtio::SocketAddr) -> IoResult<()> {
let (dst, dstlen) = addr_to_sockaddr(dst);
let dstp = &dst as *const _ as *const libc::sockaddr;
let dstlen = dstlen as libc::socklen_t;
Expand Down
4 changes: 2 additions & 2 deletions src/librustrt/rtio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ pub trait RtioSocket {
}

pub trait RtioUdpSocket : RtioSocket {
fn recvfrom(&mut self, buf: &mut [u8]) -> IoResult<(uint, SocketAddr)>;
fn sendto(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()>;
fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(uint, SocketAddr)>;
fn send_to(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()>;

fn join_multicast(&mut self, multi: IpAddr) -> IoResult<()>;
fn leave_multicast(&mut self, multi: IpAddr) -> IoResult<()>;
Expand Down
4 changes: 2 additions & 2 deletions src/librustuv/homing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ mod test {
let listener = UdpWatcher::bind(local_loop(), addr2);
tx.send((listener.unwrap(), addr1));
let mut listener = UdpWatcher::bind(local_loop(), addr1).unwrap();
listener.sendto([1, 2, 3, 4], addr2).ok().unwrap();
listener.send_to([1, 2, 3, 4], addr2).ok().unwrap();
});

let task = pool.task(TaskOpts::new(), proc() {
let (mut watcher, addr) = rx.recv();
let mut buf = [0, ..10];
assert!(watcher.recvfrom(buf).ok().unwrap() == (4, addr));
assert!(watcher.recv_from(buf).ok().unwrap() == (4, addr));
});
pool.spawn_sched().send(sched::TaskFromFriend(task));

Expand Down
30 changes: 15 additions & 15 deletions src/librustuv/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl rtio::RtioSocket for UdpWatcher {
}

impl rtio::RtioUdpSocket for UdpWatcher {
fn recvfrom(&mut self, buf: &mut [u8])
fn recv_from(&mut self, buf: &mut [u8])
-> Result<(uint, rtio::SocketAddr), IoError>
{
let loop_ = self.uv_loop();
Expand Down Expand Up @@ -607,7 +607,7 @@ impl rtio::RtioUdpSocket for UdpWatcher {
}
}

fn sendto(&mut self, buf: &[u8], dst: rtio::SocketAddr) -> Result<(), IoError> {
fn send_to(&mut self, buf: &[u8], dst: rtio::SocketAddr) -> Result<(), IoError> {
let m = self.fire_homing_missile();
let loop_ = self.uv_loop();
let guard = try!(self.write_access.grant(m));
Expand Down Expand Up @@ -960,7 +960,7 @@ mod test {
Ok(mut w) => {
tx.send(());
let mut buf = [0u8, ..10];
match w.recvfrom(buf) {
match w.recv_from(buf) {
Ok((10, addr)) => assert!(addr == client),
e => fail!("{:?}", e),
}
Expand All @@ -976,7 +976,7 @@ mod test {
let mut w = match UdpWatcher::bind(local_loop(), client) {
Ok(w) => w, Err(e) => fail!("{:?}", e)
};
match w.sendto([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], server) {
match w.send_to([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], server) {
Ok(()) => {}, Err(e) => fail!("{:?}", e)
}
}
Expand All @@ -992,7 +992,7 @@ mod test {
Ok(mut w) => {
tx.send(());
let mut buf = [0u8, ..10];
match w.recvfrom(buf) {
match w.recv_from(buf) {
Ok((10, addr)) => assert!(addr == client),
e => fail!("{:?}", e),
}
Expand All @@ -1008,7 +1008,7 @@ mod test {
let mut w = match UdpWatcher::bind(local_loop(), client) {
Ok(w) => w, Err(e) => fail!("{:?}", e)
};
match w.sendto([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], server) {
match w.send_to([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], server) {
Ok(()) => {}, Err(e) => fail!("{:?}", e)
}
}
Expand Down Expand Up @@ -1057,16 +1057,16 @@ mod test {
spawn(proc() {
let mut client = UdpWatcher::bind(local_loop(), client_addr).unwrap();
rx.recv();
assert!(client.sendto([1], server_addr).is_ok());
assert!(client.sendto([2], server_addr).is_ok());
assert!(client.send_to([1], server_addr).is_ok());
assert!(client.send_to([2], server_addr).is_ok());
});

let mut server = UdpWatcher::bind(local_loop(), server_addr).unwrap();
tx.send(());
let mut buf1 = [0];
let mut buf2 = [0];
let (nread1, src1) = server.recvfrom(buf1).ok().unwrap();
let (nread2, src2) = server.recvfrom(buf2).ok().unwrap();
let (nread1, src1) = server.recv_from(buf1).ok().unwrap();
let (nread2, src2) = server.recv_from(buf2).ok().unwrap();
assert_eq!(nread1, 1);
assert_eq!(nread2, 1);
assert!(src1 == client_addr);
Expand Down Expand Up @@ -1098,10 +1098,10 @@ mod test {
let mut buf = [1];
while buf[0] == 1 {
// send more data
assert!(server_out.sendto(msg, client_in_addr).is_ok());
assert!(server_out.send_to(msg, client_in_addr).is_ok());
total_bytes_sent += msg.len();
// check if the client has received enough
let res = server_in.recvfrom(buf);
let res = server_in.recv_from(buf);
assert!(res.is_ok());
let (nread, src) = res.ok().unwrap();
assert_eq!(nread, 1);
Expand All @@ -1120,9 +1120,9 @@ mod test {
let mut buf = [0, .. 2048];
while total_bytes_recv < MAX {
// ask for more
assert!(client_out.sendto([1], server_in_addr).is_ok());
assert!(client_out.send_to([1], server_in_addr).is_ok());
// wait for data
let res = client_in.recvfrom(buf);
let res = client_in.recv_from(buf);
assert!(res.is_ok());
let (nread, src) = res.ok().unwrap();
assert!(src == server_out_addr);
Expand All @@ -1132,7 +1132,7 @@ mod test {
}
}
// tell the server we're done
assert!(client_out.sendto([0], server_in_addr).is_ok());
assert!(client_out.send_to([0], server_in_addr).is_ok());
}

#[test]
Expand Down
Loading