Skip to content

Commit 8173e1f

Browse files
pvachonwycats
authored andcommitted
Change sendto to return bytes sent successfully
1 parent eb73213 commit 8173e1f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/sys/socket.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ pub fn recvfrom(sockfd: Fd, buf: &mut [u8], addr: &mut SockAddr) -> SysResult<ui
348348
Ok(ret as uint)
349349
}
350350

351-
pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr) -> SysResult<()> {
351+
pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr) -> SysResult<uint> {
352352
let len = match *addr {
353353
SockIpV4(_) => mem::size_of::<sockaddr_in>(),
354354
SockIpV6(_) => mem::size_of::<sockaddr_in6>(),
@@ -358,10 +358,10 @@ pub fn sendto(sockfd: Fd, buf: &[u8], addr: &SockAddr) -> SysResult<()> {
358358
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) };
359359

360360
if ret < 0 {
361-
return Err(SysError::last());
361+
Err(SysError::last())
362+
} else {
363+
Ok(ret as uint)
362364
}
363-
364-
Ok(())
365365
}
366366

367367
#[repr(C)]

0 commit comments

Comments
 (0)