Skip to content

Commit

Permalink
[wip] make write_overlap return the amount of written bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
steffengy committed Jan 19, 2017
1 parent e35553a commit a37c31d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub trait TcpStreamExt {
/// the port.
unsafe fn write_overlapped(&self,
buf: &[u8],
overlapped: &mut Overlapped) -> io::Result<bool>;
overlapped: &mut Overlapped) -> io::Result<(bool, usize)>;

/// Execute a connection operation for this socket.
///
Expand Down Expand Up @@ -475,11 +475,12 @@ impl TcpStreamExt for TcpStream {
}

unsafe fn write_overlapped(&self, buf: &[u8],
overlapped: &mut Overlapped) -> io::Result<bool> {
overlapped: &mut Overlapped) -> io::Result<(bool, usize)> {
let mut buf = slice2buf(buf);
let mut size: DWORD = 0;
let r = WSASend(self.as_raw_socket(), &mut buf, 1,
0 as *mut _, 0, overlapped.raw(), None);
cvt(r)
&mut size, 0, overlapped.raw(), None);
cvt(r).map(|state| (state, size as usize))
}

unsafe fn connect_overlapped(&self, addr: &SocketAddr,
Expand Down

0 comments on commit a37c31d

Please sign in to comment.