aboutsummaryrefslogtreecommitdiff
path: root/slirp/socket.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-10-07 23:27:35 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-10-07 23:27:35 +0000
commit02d2c54cd3e1a65ce4eaf1555b7f73d0a50eaec4 (patch)
tree52c827b911f8ce0cc99998198dc0fef5abee3c97 /slirp/socket.c
parent890fa6bebbb540b9761aafc3fe37b87e26578346 (diff)
windows fixes (Gregory Alexander)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1102 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'slirp/socket.c')
-rw-r--r--slirp/socket.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/slirp/socket.c b/slirp/socket.c
index 7286b5e19f..fe03d448a5 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -152,7 +152,7 @@ soread(so)
nn = readv(so->s, (struct iovec *)iov, n);
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
#else
- nn = read(so->s, iov[0].iov_base, iov[0].iov_len);
+ nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0);
#endif
if (nn <= 0) {
if (nn < 0 && (errno == EINTR || errno == EAGAIN))
@@ -176,7 +176,7 @@ soread(so)
* A return of -1 wont (shouldn't) happen, since it didn't happen above
*/
if (n == 2 && nn == iov[0].iov_len)
- nn += read(so->s, iov[1].iov_base, iov[1].iov_len);
+ nn += recv(so->s, iov[1].iov_base, iov[1].iov_len,0);
DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn));
#endif
@@ -333,7 +333,7 @@ sowrite(so)
DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn));
#else
- nn = write(so->s, iov[0].iov_base, iov[0].iov_len);
+ nn = send(so->s, iov[0].iov_base, iov[0].iov_len,0);
#endif
/* This should never happen, but people tell me it does *shrug* */
if (nn < 0 && (errno == EAGAIN || errno == EINTR))
@@ -349,7 +349,7 @@ sowrite(so)
#ifndef HAVE_READV
if (n == 2 && nn == iov[0].iov_len)
- nn += write(so->s, iov[1].iov_base, iov[1].iov_len);
+ nn += send(so->s, iov[1].iov_base, iov[1].iov_len,0);
DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn));
#endif
@@ -572,7 +572,11 @@ solisten(port, laddr, lport, flags)
close(s);
sofree(so);
/* Restore the real errno */
+#ifdef _WIN32
+ WSASetLastError(tmperrno);
+#else
errno = tmperrno;
+#endif
return NULL;
}
setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int));
@@ -643,7 +647,9 @@ sofcantrcvmore(so)
{
if ((so->so_state & SS_NOFDREF) == 0) {
shutdown(so->s,0);
- FD_CLR(so->s, global_writefds);
+ if(global_writefds) {
+ FD_CLR(so->s,global_writefds);
+ }
}
so->so_state &= ~(SS_ISFCONNECTING);
if (so->so_state & SS_FCANTSENDMORE)
@@ -657,9 +663,13 @@ sofcantsendmore(so)
struct socket *so;
{
if ((so->so_state & SS_NOFDREF) == 0) {
- shutdown(so->s,1); /* send FIN to fhost */
- FD_CLR(so->s, global_readfds);
- FD_CLR(so->s, global_xfds);
+ shutdown(so->s,1); /* send FIN to fhost */
+ if (global_readfds) {
+ FD_CLR(so->s,global_readfds);
+ }
+ if (global_xfds) {
+ FD_CLR(so->s,global_xfds);
+ }
}
so->so_state &= ~(SS_ISFCONNECTING);
if (so->so_state & SS_FCANTRCVMORE)