summaryrefslogtreecommitdiffstats
path: root/win/tclWinSock.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r--win/tclWinSock.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index bb6c690..d37d39b 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -1137,26 +1137,15 @@ TcpClose2Proc(
int flags) /* Flags that indicate which side to close. */
{
TcpState *statePtr = (TcpState *)instanceData;
- int errorCode = 0;
- int sd;
+ int readError = 0;
+ int writeError = 0;
/*
* Shutdown the OS socket handle.
*/
- switch(flags) {
- case TCL_CLOSE_READ:
- sd = SD_RECEIVE;
- break;
- case TCL_CLOSE_WRITE:
- sd = SD_SEND;
- break;
- default:
- if (interp) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "socket close2proc called bidirectionally", -1));
- }
- return TCL_ERROR;
+ if ((flags & (TCL_CLOSE_READ|TCL_CLOSE_WRITE)) == 0) {
+ return TcpCloseProc(instanceData, interp);
}
/*
@@ -1164,12 +1153,15 @@ TcpClose2Proc(
* TCL_WRITABLE so this should never be called for a server socket.
*/
- if (shutdown(statePtr->sockets->fd, sd) == SOCKET_ERROR) {
+ if ((flags & TCL_CLOSE_READ) && (shutdown(statePtr->sockets->fd, SD_RECEIVE) == SOCKET_ERROR)) {
TclWinConvertError((DWORD) WSAGetLastError());
- errorCode = Tcl_GetErrno();
+ readError = Tcl_GetErrno();
}
-
- return errorCode;
+ if ((flags & TCL_CLOSE_WRITE) && (shutdown(statePtr->sockets->fd, SD_SEND) == SOCKET_ERROR)) {
+ TclWinConvertError((DWORD) WSAGetLastError());
+ writeError = Tcl_GetErrno();
+ }
+ return (readError != 0) ? readError : writeError;
}
/*