summaryrefslogtreecommitdiffstats
path: root/generic/tclIOSock.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-08-04 07:47:22 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-08-04 07:47:22 (GMT)
commitef03a2c7809309b2255f7c82c6abe0db2e4160bf (patch)
treefd7b6368f954a4c1a95289f5dc388a409605c11c /generic/tclIOSock.c
parentbf9624b12a9e6fe010e025b8f76d3e29c8399725 (diff)
parent24ef33dc101a3e9114318b884c1e99d792f4739d (diff)
downloadtcl-ef03a2c7809309b2255f7c82c6abe0db2e4160bf.zip
tcl-ef03a2c7809309b2255f7c82c6abe0db2e4160bf.tar.gz
tcl-ef03a2c7809309b2255f7c82c6abe0db2e4160bf.tar.bz2
merge trunk
Diffstat (limited to 'generic/tclIOSock.c')
-rw-r--r--generic/tclIOSock.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/generic/tclIOSock.c b/generic/tclIOSock.c
index 7b7b647..018f9f5 100644
--- a/generic/tclIOSock.c
+++ b/generic/tclIOSock.c
@@ -87,8 +87,8 @@ TclSockGetPort(
*----------------------------------------------------------------------
*/
-#ifndef _WIN32
-# define SOCKET size_t
+#if !defined(_WIN32) && !defined(__CYGWIN__)
+# define SOCKET int
#endif
int
@@ -100,16 +100,16 @@ TclSockMinimumBuffers(
socklen_t len;
len = sizeof(int);
- getsockopt((SOCKET)sock, SOL_SOCKET, SO_SNDBUF, (char *)&current, &len);
+ getsockopt((SOCKET)(size_t)sock, SOL_SOCKET, SO_SNDBUF, (char *)&current, &len);
if (current < size) {
len = sizeof(int);
- setsockopt((SOCKET)sock, SOL_SOCKET, SO_SNDBUF, (char *)&size, len);
+ setsockopt((SOCKET)(size_t)sock, SOL_SOCKET, SO_SNDBUF, (char *)&size, len);
}
len = sizeof(int);
- getsockopt((SOCKET)sock, SOL_SOCKET, SO_RCVBUF, (char *)&current, &len);
+ getsockopt((SOCKET)(size_t)sock, SOL_SOCKET, SO_RCVBUF, (char *)&current, &len);
if (current < size) {
len = sizeof(int);
- setsockopt((SOCKET)sock, SOL_SOCKET, SO_RCVBUF, (char *)&size, len);
+ setsockopt((SOCKET)(size_t)sock, SOL_SOCKET, SO_RCVBUF, (char *)&size, len);
}
return TCL_OK;
}
@@ -206,7 +206,13 @@ TclCreateSocketAddress(
}
if (result != 0) {
- goto error;
+#ifdef EAI_SYSTEM /* Doesn't exist on Windows */
+ if (result == EAI_SYSTEM)
+ *errorMsgPtr = Tcl_PosixError(interp);
+ else
+#endif
+ *errorMsgPtr = gai_strerror(result);
+ return 0;
}
/*
@@ -249,33 +255,6 @@ TclCreateSocketAddress(
}
return 1;
-
- /*
- * Ought to use gai_strerror() here...
- */
-
-error:
- switch (result) {
- case EAI_NONAME:
- case EAI_SERVICE:
-#if defined(EAI_ADDRFAMILY) && EAI_ADDRFAMILY != EAI_NONAME
- case EAI_ADDRFAMILY:
-#endif
-#if defined(EAI_NODATA) && EAI_NODATA != EAI_NONAME
- case EAI_NODATA:
-#endif
- *errorMsgPtr = gai_strerror(result);
- errno = EHOSTUNREACH;
- return 0;
-#ifdef EAI_SYSTEM
- case EAI_SYSTEM:
- return 0;
-#endif
- default:
- *errorMsgPtr = gai_strerror(result);
- errno = ENXIO;
- return 0;
- }
}
/*