tclUnixChan.diff	vºz©Eºz©LmBINh,Index: unix/tclUnixChan.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixChan.c,v
retrieving revision 1.41
diff -u -r1.41 tclUnixChan.c
--- unix/tclUnixChan.c	26 Jan 2003 05:59:37 -0000	1.41
+++ unix/tclUnixChan.c	20 Feb 2003 04:48:26 -0000
@@ -294,6 +294,10 @@
 #endif	/* SUPPORTS_TTY */
 static int		WaitForConnect _ANSI_ARGS_((TcpState *statePtr,
 			    int *errorCodePtr));
+static Tcl_Channel	MakeTcpClientChannelMode _ANSI_ARGS_(
+			    (ClientData tcpSocket,
+			    int mode));
+
 
 /*
  * This structure describes the channel type structure for file based IO:
@@ -1916,10 +1920,7 @@
 #endif /* SUPPORTS_TTY */
     if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (VOID *)&socketType,
 		   &argLength) == 0  &&	 socketType == SOCK_STREAM) {
-	/*
-	 * The mode parameter gets lost here, unfortunately.
-	 */
-	return Tcl_MakeTcpClientChannel((ClientData) fd);
+	return MakeTcpClientChannelMode((ClientData) fd, mode);
     } else {
 	channelTypePtr = &fileChannelType;
 	fsPtr = (FileState *) ckalloc((unsigned) sizeof(FileState));
@@ -2765,6 +2766,32 @@
 Tcl_MakeTcpClientChannel(sock)
     ClientData sock;		/* The socket to wrap up into a channel. */
 {
+    return MakeTcpClientChannelMode(sock, (TCL_READABLE | TCL_WRITABLE));
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * MakeTcpClientChannelMode --
+ *
+ *	Creates a Tcl_Channel from an existing client TCP socket
+ *	with given mode.
+ *
+ * Results:
+ *	The Tcl_Channel wrapped around the preexisting TCP socket.
+ *
+ * Side effects:
+ *	None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static Tcl_Channel
+MakeTcpClientChannelMode(sock, mode)
+    ClientData sock;		/* The socket to wrap up into a channel. */
+    int mode;			/* ORed combination of TCL_READABLE and
+				 * TCL_WRITABLE to indicate file mode. */
+{
     TcpState *statePtr;
     char channelName[16 + TCL_INTEGER_SPACE];
 
@@ -2777,7 +2804,7 @@
     sprintf(channelName, "sock%d", statePtr->fd);
 
     statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
-	    (ClientData) statePtr, (TCL_READABLE | TCL_WRITABLE));
+	    (ClientData) statePtr, mode);
     if (Tcl_SetChannelOption((Tcl_Interp *) NULL, statePtr->channel,
 	    "-translation", "auto crlf") == TCL_ERROR) {
 	Tcl_Close((Tcl_Interp *) NULL, statePtr->channel);
