diff options
author | Tim Champagne <tchamp@users.sourceforge.net> | 2003-06-11 00:51:23 +0000 |
---|---|---|
committer | Tim Champagne <tchamp@users.sourceforge.net> | 2003-06-11 00:51:23 +0000 |
commit | 7ed53e0ca4f460146aeab7ea7db5f6db1a147885 (patch) | |
tree | 95cbe7b34f64aec3bb3eaedcb2a73e6cc73bce30 | |
parent | 682502d274bfac088a084b97d543a40fcf1cbfce (diff) | |
download | xine-lib-7ed53e0ca4f460146aeab7ea7db5f6db1a147885.tar.gz xine-lib-7ed53e0ca4f460146aeab7ea7db5f6db1a147885.tar.bz2 |
Fix io_helper for Win32. The http plugin now works again for Win32
CVS patchset: 5024
CVS date: 2003/06/11 00:51:23
-rw-r--r-- | src/xine-engine/io_helper.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/xine-engine/io_helper.c b/src/xine-engine/io_helper.c index a6d1b5fec..60a24c685 100644 --- a/src/xine-engine/io_helper.c +++ b/src/xine-engine/io_helper.c @@ -61,11 +61,25 @@ int xio_tcp_connect(xine_stream_t *stream, const char *host, int port) { xine_message(stream, XINE_MSG_CONNECTION_REFUSED, "failed to create socket", strerror(errno), NULL); return -1; } - + +#ifndef _MSC_VER if (fcntl (s, F_SETFL, fcntl (s, F_GETFL) | O_NONBLOCK) == -1) { xine_message(stream, XINE_MSG_CONNECTION_REFUSED, "can't put socket in non-blocking mode", strerror(errno), NULL); return -1; } +#else + { + int non_block = 1; + int rc; + + rc = ioctlsocket(s, FIONBIO, &non_block); + + if (rc == SOCKET_ERROR) { + xine_message(stream, XINE_MSG_CONNECTION_REFUSED, "can't put socket in non-blocking mode", strerror(errno), NULL); + return -1; + } + } +#endif for (i = 0; h->h_addr_list[i]; i++) { struct in_addr ia; @@ -79,12 +93,15 @@ int xio_tcp_connect(xine_stream_t *stream, const char *host, int port) { #ifndef WIN32 if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && errno != EINPROGRESS) { #else - if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && WSAGetLastError() != WSAEINPROGRESS) { + if (connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1 && WSAGetLastError() != WSAEWOULDBLOCK) { + printf("io_helper: WSAGetLastError() = %d\n", WSAGetLastError()); #endif /* WIN32 */ + xine_message(stream, XINE_MSG_CONNECTION_REFUSED, strerror(errno), NULL); close(s); continue; - } + } + return s; } return -1; |