diff options
author | Phil Vachon <phil@cowpig.ca> | 2014-10-20 21:12:18 -0400 |
---|---|---|
committer | Phil Vachon <phil@cowpig.ca> | 2014-10-20 21:12:18 -0400 |
commit | 6bb4f399d9dfcae45f117a34d24d142d49bcdca3 (patch) | |
tree | d4b9222436335b7ddff916cfb3fd8a5518d0042e /src/sys/socket.rs | |
parent | af1c5400a2fe1048b09df408eee1b29acb7564de (diff) | |
download | nix-6bb4f399d9dfcae45f117a34d24d142d49bcdca3.zip |
Change sendto to return bytes sent successfully
Diffstat (limited to 'src/sys/socket.rs')
-rw-r--r-- | src/sys/socket.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/sys/socket.rs b/src/sys/socket.rs index f8b245e2..08f2515c 100644 --- a/src/sys/socket.rs +++ b/src/sys/socket.rs @@ -348,7 +348,7 @@ pub fn recvfrom(sockfd: Fd, buf: &mut [u8], addr: &mut SockAddr) -> SysResult<ui Ok(ret as uint) } -pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr) -> SysResult<()> { +pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr) -> SysResult<uint> { let len = match *addr { SockIpV4(_) => mem::size_of::<sockaddr_in>(), SockIpV6(_) => mem::size_of::<sockaddr_in6>(), @@ -358,10 +358,10 @@ pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr) -> SysResult<()> { let ret = unsafe { ffi::sendto(sockfd, buf.as_ptr() as *const c_void, buf.len() as size_t, 0, mem::transmute(addr), len as socklen_t) }; if ret < 0 { - return Err(SysError::last()); + Err(SysError::last()) + } else { + Ok(ret as uint) } - - Ok(()) } #[repr(C)] |