summaryrefslogtreecommitdiffstats
path: root/win/tclWinSock.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-05-22 12:44:36 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-05-22 12:44:36 (GMT)
commit056ec20e9eb07aded13c8edd3a39a65512c52929 (patch)
tree547f1279c0ce411de4125eaac91a118af4215da5 /win/tclWinSock.c
parent3d7e78f01cd6ddb05fa76bfc7aeb0c9c61392dfa (diff)
parent669d1c9df8e9d7c24e567111f7d6ab59b69caf4a (diff)
downloadtcl-056ec20e9eb07aded13c8edd3a39a65512c52929.zip
tcl-056ec20e9eb07aded13c8edd3a39a65512c52929.tar.gz
tcl-056ec20e9eb07aded13c8edd3a39a65512c52929.tar.bz2
Revert most of [fcc5957e59], since when we let cygwin share the win32 stub table this is no longer necessary
implement TclpInetNtoa for win32 Let cygwin share stub table with win32
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r--win/tclWinSock.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index 019d8e9..9591163 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -1129,7 +1129,7 @@ CreateSocketAddress(
ZeroMemory(sockaddrPtr, sizeof(SOCKADDR_IN));
sockaddrPtr->sin_family = AF_INET;
- sockaddrPtr->sin_port = htons((u_short) (port & 0xFFFF));
+ sockaddrPtr->sin_port = htons((unsigned short) (port & 0xFFFF));
if (host == NULL) {
addr.s_addr = INADDR_ANY;
} else {
@@ -2512,9 +2512,25 @@ TclWinSetSockOpt(SOCKET s, int level, int optname, const char *optval,
return setsockopt(s, level, optname, optval, optlen);
}
-u_short
-TclWinNToHS(
- u_short netshort)
+unsigned short
+TclWinNToHS(unsigned short netshort)
+{
+ /*
+ * Check that WinSock is initialized; do not call it if not, to
+ * prevent system crashes. This can happen at exit time if the exit
+ * handler for WinSock ran before other exit handlers that want to
+ * use sockets.
+ */
+
+ if (!SocketsEnabled()) {
+ return (unsigned short) -1;
+ }
+
+ return ntohs(netshort);
+}
+
+char *
+TclpInetNtoa(struct in_addr addr)
{
/*
* Check that WinSock is initialized; do not call it if not, to prevent
@@ -2523,10 +2539,10 @@ TclWinNToHS(
*/
if (!SocketsEnabled()) {
- return (u_short) -1;
+ return NULL;
}
- return ntohs(netshort);
+ return inet_ntoa(addr);
}
struct servent *