Artifacts Associated With Ticket 219137
Ticket change [dc888e265a] (rid 114497) by nobody on 2000-10-26 05:02:13:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized 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; - foundin initialized to: "obsolete: 8.1a2"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "63. (unused)"
- title initialized to: "stdin is a "file"; it should be a socket"
- type initialized to: "Patch"
Ticket change [7a9ab2a8f0] (rid 90356) by dkf on 2000-11-10 20:36:36:
- icomment:
Sounds like a reasonable request to me, though it is a UNIX-specific change as Windows places sockets and pipes/terminals into mutually exclusive sets. Stupid operating system... I wouldn't fix it exactly as described though; if we are going to allow stdio channels to be represented as socket channels, then they should have names from the sock* series as well. Also ought to check errno to figure out if we've really got a socket (succeeds => yes, fails with errno==ENOTSOCK => no, other failures => machine is very short of resources!)
- login: "dkf"
- mimetype: "text/plain"
- priority changed to: "4"
- username: "dkf"
- icomment:
Ticket change [efb5c975ed] (rid 109048) by dgp on 2001-04-01 01:47:33:
- subsystem changed to: "27. Channel Types"
- title changed to: "stdin is a "file"; it should be a socket"
Ticket change [ab99fbba6b] (rid 101146) by dkf on 2001-06-06 17:38:10:
- foundin changed to: "None"
- icomment:
File Added - 7062: chantype.patch Logged In: YES user_id=79902 After investigation, I've got a solution for this (well, one that goes a bit better and handles serial lines as well.)
- login: "dkf"
- mimetype: "text/plain"
- priority changed to: "5 Medium"
- subsystem changed to: "None"
- title changed to: "stdin is a file; it should be a socket"
- username: "dkf"
Ticket change [201e38fa5c] (rid 91259) by dkf on 2001-06-06 19:50:03:
- icomment:
File Deleted - 7062:
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [56fd092f79] (rid 94416) by dkf on 2001-06-06 19:51:49:
- icomment:
Logged In: YES user_id=79902 (Bah! Next time check that it really works *first*; this new version seems to do the business though.)
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Add attachment "unixchantype.patch" [d6512aed10] (rid 123780) by dkf on 2001-06-06 19:51:49.
Ticket change [a4f42f143c] (rid 110288) by dkf on 2001-06-06 19:51:50:
- icomment:
File Added - 7067: unixchantype.patch
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [8364ec2a05] (rid 117376) by dkf on 2001-06-18 21:49:32:
- assignee changed to: "dkf"
- closedate changed to: "2001-06-18T14:49:32"
- closer changed to: "dkf"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [ffc87af0b0] (rid 108822) by dgp on 2001-10-24 23:27:06:
- icomment:
Logged In: YES user_id=80530 Re-opening this patch since it appears to have introduced new bugs. http://sf.net/tracker/?func=detail&atid=110894&aid=471374&group_id=10894 http://sf.net/tracker/index.php?func=detail&aid=465761&group_id=12997&atid=112997
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Open"
- username: "dgp"
- icomment:
Ticket change [caf9f79d92] (rid 95450) by dkf on 2001-10-25 22:52:56:
- status changed to: "Closed"
Ticket change [503640cc14] (rid 125929) by dkf on 2001-10-25 22:52:57:
- closedate changed to: "2001-10-25T15:52:57"
- closer changed to: "dkf"
Ticket change [8d668c02cf] (rid 127921) by dkf on 2001-10-25 23:14:14:
- closedate changed to: "2001-10-25T16:14:14"
- closer changed to: "dkf"
- resolution changed to: "Fixed"
- subsystem changed to: "27. Channel Types"