Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-05-25
02:06 • Closed ticket [557878ffff]: server fails with -encoding binary plus 6 other ... artifact: ca46cbb709 user: andreas_kupries
01:54 • Ticket [557878ffff]: 5 changes artifact: bf93297065 user: andreas_kupries
01:54 • Add attachment 557878.diff to ticket [557878ffff] artifact: 9af03b02bc user: andreas_kupries
01:26 • Ticket [557878ffff] server fails with -encoding binary status still Open wit... artifact: 217985b200 user: andreas_kupries
00:35 • Ticket [557878ffff]: 4 changes artifact: a0f291b283 user: andreas_kupries
00:32 • Ticket [557878ffff]: 4 changes artifact: 991424b1eb user: andreas_kupries
2002-05-22
01:28 • Ticket [557878ffff]: 1 change artifact: bc86485c2f user: andreas_kupries
00:25 • Ticket [557878ffff]: 1 change artifact: fa8dd58ee6 user: andreas_kupries
2002-05-21
01:50 • Ticket [557878ffff]: 1 change artifact: b00279b236 user: dgp
2002-05-20
16:26 • Ticket [557878ffff]: 2 changes artifact: 5ddf97443d user: dkf
2002-05-19
06:18 • New ticket [557878ffff]. artifact: 98a3905baf user: nobody

server fails with -encoding binary

Closed / Fixed557878ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2002-05-19 06:18:41
The bug affects Tcl 8.3.2 - 8.4a5  When a server 
socket is created and "fconfigure $sock -encoding 
binary" is used the server fails to call the proc 
specified in the socket -server command.  The end 
result is that client sockets fail to be able to 
connect.  This problem doesn't affect Unix-like 
(OpenBSD 3.0) systems from the tests that I've run.  
I and another person were able to verify that it 
fails in Windows.  I tested it with Windows XP.

Now, I know that fconfiguring a server socket is 
apparently pointless as DKF put it I believe, but it 
is a bug nonetheless.
dkf Ticket [557878ffff]: 2 changes [History diff]2002-05-20 16:26:52
dgp Ticket [557878ffff]: 1 change [History diff]2002-05-21 01:50:51
andreas_kupries Ticket [557878ffff]: 1 change [History diff]2002-05-22 00:25:32
andreas_kupries Ticket [557878ffff]: 1 change [History diff]2002-05-22 01:28:55
andreas_kupriesplain2002-05-25 00:32:33
Logged In: YES 
user_id=75003

Confirmed for Win2K.
andreas_kupriesplain2002-05-25 00:35:41
Logged In: YES 
user_id=75003

Actually setting any encoding, even the encoding reported 
back by fconfigure will cause the problem. In other words, the 
problem is not so much in the specific encoding chosen, but 
the act of performing the reconfiguration of the server socket.
andreas_kupriesplain2002-05-25 01:26:58
Logged In: YES 
user_id=75003

Yep. What happens is this: When the server socket is 
reconfigured the system will call TcpWatchProc in 
tclWinSock.c to update for which events to look. Adding 
some tracing statements to this routine we see:

$ ./bin/tclsh84s.exe
% fconfigure [set a [socket -server hoo 0]] -sockname
0.0.0.0 0.0.0.0 1143
% fconfigure $a -encoding 1143
unknown encoding "1143"
% fconfigure $a -encoding binary
FD_READ    = 001
FD_WRITE   = 002
FD_CLOSE   = 032
FD_ACCEPT  = 008
FD_CONNECT = 016
watch      = 008
select     = 008
watch/new  = 000
select/new = 008

watch determines which events are watched by windows for 
the handle, and ACCEPT is the event sent if a new 
connection arrives on the socket. As we can see the 
ACCEPT is cleared completely. This is because the server 
socket is neither readable nor writable.

Unix systems are not affected because they check if an 
acceptProc is set (tclUnixChan.c, line 2354, TcpWatchProc) 
and avoid messing with the masks and events if that it so.

We have to perform the same check for Windows.

The mechanism on Mac is unclear. This means that this
report has to be given to the mac maintainers to make sure
that this bug is not present for that platform too.
andreas_kupriesplain2002-05-25 01:54:30
File Added - 23688: 557878.diff

Logged In: YES 
user_id=75003

Attaching a patch.
andreas_kupriesplain2002-05-25 02:06:07
Logged In: YES 
user_id=75003

Patch committed.
Log in (anonymous is fine) to add a comment.

Attachments: