Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: dc888e265a09e64d9b5de1845b5491a66419691d
Ticket: 219137ffffffffffffffffffffffffffffffffff
stdin is a file; it should be a socket
User & Date: nobody on 2000-10-26 05:02:13
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 621 RFE
    Version: 8.1a2
    SubmitDate: '1998-05-25'
    LastModified: '1999-03-23'
    Severity: LOW
    Status: Assigned
    Submitter: hershey
    ChangedBy: surles
    OS: All
    OSVersion: NA
    Machine: NA
    FixedDate: '2000-10-25'
    FixedInVersion: NA
    ClosedDate: '2000-10-25'
    
    
    I have a Tcl script started from the inetd daemon but am unable to get
    
    [fconfigure stdin -peername] because stdin is a 'file' rather than a
    
    'socket'.  The following patch to tcl8.1a2/unix/tclUnixChan.c (v 1.217)
    
    modifies the Tcl_MakeFileChannel() function to make a channel with the
    
    socket ('tcp') channel type if it responds sucessfully to a
    
    getsockname() request.
    
    
    
    Could you please include this change in future versions of Tcl?  If you
    
    are the wrong person to send this to please let me know.
    
    
    
    I have to say that the SUPPORTS_TTY logic in Tcl_OpenFileChannel()
    
    should probably also be present in the Tcl_MakeFileChannel() function as
    
    well.
    
    ---
    
    Matthew Costello
    
    (619)485-2926
    
    [email protected]
    
    *** tclUnixChan.c.ORIG  Fri Feb 20 15:20:43 1998
    
    --- tclUnixChan.c       Thu Apr 30 16:10:49 1998
    
    ***************
    
    *** 1387,1392 ****
    
    --- 1387,1398 ----
    
          char channelName[16 + TCL_INTEGER_SPACE];
    
          int fd = (int) handle;
    
          ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
    
    +     Tcl_ChannelType *channelTypePtr;
    
    + #define SUPPORTS_SOCKET
    
    + #ifdef SUPPORTS_SOCKET
    
    +     struct sockaddr sockaddr;
    
    +     int socklen = sizeof(sockaddr);
    
    + #endif
    
      
    
          if (mode == 0) {
    
              return NULL;
    
    ***************
    
    *** 1410,1418 ****
    
          fsPtr->nextPtr = tsdPtr->firstFilePtr;
    
          tsdPtr->firstFilePtr = fsPtr;
    
      
    
          fsPtr->fd = fd;
    
          fsPtr->validMask = mode | TCL_EXCEPTION;
    
    !     fsPtr->channel = Tcl_CreateChannel(&fileChannelType, channelName,
    
                  (ClientData) fsPtr, mode);
    
          
    
          return fsPtr->channel;
    
    --- 1416,1441 ----
    
          fsPtr->nextPtr = tsdPtr->firstFilePtr;
    
          tsdPtr->firstFilePtr = fsPtr;
    
      
    
    + #ifdef SUPPORTS_SOCKET
    
    +     if (getsockname(fd,&sockaddr,&socklen ) == 0) {
    
    +       /*
    
    +       * Initialize the serial port to a set of sane parameters.
    
    +       * Especially important if the remote device is set to echo and
    
    +       * the serial port driver was also set to echo -- as soon as a char
    
    +       * were sent to the serial port, the remote device would echo it,
    
    +       * then the serial driver would echo it back to the device, etc.
    
    +       */
    
    +       
    
    +       channelTypePtr = &tcpChannelType;
    
    +     } else 
    
    + #endif        /* SUPPORTS_SOCKET */
    
    +     {
    
    +       channelTypePtr = &fileChannelType;
    
    +     }
    
    + 
    
          fsPtr->fd = fd;
    
          fsPtr->validMask = mode | TCL_EXCEPTION;
    
    !     fsPtr->channel = Tcl_CreateChannel(channelTypePtr, channelName,
    
                  (ClientData) fsPtr, mode);
    
          
    
          return fsPtr->channel;
    
    
    
    
    
    
    
  4. foundin changed to: "obsolete: 8.1a2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "63. (unused)"
  10. title changed to: "stdin is a "file"; it should be a socket"
  11. type changed to: "Patch"