List Info

Thread: Non-Blocking Socket Problem




Non-Blocking Socket Problem
user name
2006-08-17 17:41:15
Dear Aqua Interface Programmers,

I asked earlier if any significant work had been done on the
TCL/MacOS 
socket handling between 8.4.10 and 8.4.13. From the silence,
I assume not.

Nevertheless, Wish 8.4.12 freezes when we move windows
around during 
TCPIP data transfer, while 8.4.11 does not. I'd like to
know if this is 
a MacOS interface problem, or a core TCL problem. If it's a
core TCL 
problem, I'll take it to another forum.

Here's how to reproduce the freeze and prove to yourself
that it's a 
problem with the TCL/TK version. You'll need two copies of
Wish. One 
should be 8.4.11 or earlier. The other should be 8.4.12 or
later.

Start the <=8.4.11 Wish. Open the console. Paste the
following server 
accept procedure:

proc accept {sock addr port} {
   puts "Accepted $sock from $addr\:$port"
   fconfigure $sock -blocking 0 -translation binary
   for {set i 0} {$i < 1000} {incr i} {
     puts -nonewline $sock "0000000000"
     after 10
     update
   }
   close $sock
   puts "Closed $sock from $addr\:$port"
}

Start the server socket with:

set sock [socket -server accept 2000]

Start the >=8.4.12 Wish. Open the console. Paste the
following client 
procedure:

proc getblock {} {
   set sock [socket 0.0.0.0 2000]
   fconfigure $sock -blocking 0 -translation binary
   set bytes_remaining 10000
   fileevent $sock r [list set timeoutvar
"Reading."]
   while {$bytes_remaining > 0} {
     if {$bytes_remaining > 0} {vwait timeoutvar}
     set data [read $sock $bytes_remaining]
     set bytes_remaining [expr $bytes_remaining - [string
length $data]]
   }
   close $sock
}

Now type "getblock" in the console. The client
starts to download data 
from the server. The data comes in at 10 bytes every 10 ms,
taking a 
total of 10 seconds. If you don't touch the client, the
transfer will 
complete.

Type "getblock" again. Move the console or
master window on the client 
side (Wish version >=8.4.12) with the mouse. Move it
again and again, 
each time grabbing it and releasing it. After half a dozen
mouse-clicks, 
the client freezes. Check the MacOS system Console (Console
Utility). 
There is no error report. The client freezes, but it does
not crash.

If you quit both the client and server Wish programs, and
repeat the 
experiment with <=8.4.11 as the client, you'll find that
you can move 
the windows around as much as you like during data transfer,
and it 
never freezes. In all cases, you can move the window on the
server side 
around and it never freezes.

If you experiment with the getblock procedure, you'll find
that the 
freeze occurs during "vwait". The freeze occurs
only if the socket is 
open, free of errors, and data is coming in.

I compiled my own copies of 8.4.10, 8.4.11, 8.4.12, and
8.4.13 on a G4 
and Single-Intel mac running OS 10.4.7. I also downloaded
pre-compiled 
PPC copies of 8.4.5 and 8.4.10. I performed the above
experiments on 
both machines with all versions. On the Intel machine, the
PPC copies 
ran with Rosetta. Any client 8.4.12 or later freezes on both
machines. 
Any client 8.4.11 or earlier is robust on both machines.

Note: From what I gather, <=8.4.12 is not guaranteed to
work when 
compiled for Intel. That may be so, and these versions do
mess up colors 
in Tk_PutPhotoBlock. But they compile and they almost work.

Note: No version of PPC Wish will run on our Dual-Intel mac,
but they 
all work on our Single-Intel mac. I'm investigating.

Yours, Kevan

-- 
Kevan Hashemi, Electrical Engineer
Physics Department, Brandeis University
http://alignment.h
ep.brandeis.edu/

------------------------------------------------------------
-------------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to
make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/
sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Tcl-mac mailing list
tcl-maclists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/tcl-mac
Non-Blocking Socket Problem
user name
2006-08-17 18:40:42
Kevan Hashemi wrote:
> I asked earlier if any significant work had been done
on the TCL/MacOS 
> socket handling between 8.4.10 and 8.4.13. From the
silence, I assume not.

That is correct.  If you look at the Tcl ChangeLog between
8.4.10 and 8.4.13,
you will see no significant changes to the OS X notifier. 
There are changes
just before 8.4.10 and after 8.4.13 though.

> Nevertheless, Wish 8.4.12 freezes when we move windows
around during 
> TCPIP data transfer, while 8.4.11 does not. I'd like
to know if this is 
> a MacOS interface problem, or a core TCL problem. If
it's a core TCL 
> problem, I'll take it to another forum.

I can confirm your problem when running on a Dual-G5, server
8.4.7 (stock) and
with clients 8.4.7 (all OK), 8.4.14-head and 8.5-head (both
hang).

*However*, if I run the server as tclsh (just add a 'vwait
forever' after
creating the server socket), then I don't get a hang.  In
addition, if I run 2
wishes of the same version level (tested 8.4.14-head), then
I also don't hang.

I suspect this means that there is some OS X specific type
of interdependency
with multiple instances of the UI.  It may specifically be a
wish issue, or
something that multiple instances should just
"know", or ???

Can you please confirm that using the same version on both
ends works for you?

Jeff

> Here's how to reproduce the freeze and prove to
yourself that it's a 
> problem with the TCL/TK version. You'll need two
copies of Wish. One 
> should be 8.4.11 or earlier. The other should be 8.4.12
or later.
> 
> Start the <=8.4.11 Wish. Open the console. Paste the
following server 
> accept procedure:
> 
> proc accept {sock addr port} {
>    puts "Accepted $sock from $addr\:$port"
>    fconfigure $sock -blocking 0 -translation binary
>    for {set i 0} {$i < 1000} {incr i} {
>      puts -nonewline $sock "0000000000"
>      after 10
>      update
>    }
>    close $sock
>    puts "Closed $sock from $addr\:$port"
> }
> 
> Start the server socket with:
> 
> set sock [socket -server accept 2000]
> 
> Start the >=8.4.12 Wish. Open the console. Paste the
following client 
> procedure:
> 
> proc getblock {} {
>    set sock [socket 0.0.0.0 2000]
>    fconfigure $sock -blocking 0 -translation binary
>    set bytes_remaining 10000
>    fileevent $sock r [list set timeoutvar
"Reading."]
>    while {$bytes_remaining > 0} {
>      if {$bytes_remaining > 0} {vwait timeoutvar}
>      set data [read $sock $bytes_remaining]
>      set bytes_remaining [expr $bytes_remaining -
[string length $data]]
>    }
>    close $sock
> }
> 
> Now type "getblock" in the console. The
client starts to download data 
> from the server. The data comes in at 10 bytes every 10
ms, taking a 
> total of 10 seconds. If you don't touch the client,
the transfer will 
> complete.
> 
> Type "getblock" again. Move the console or
master window on the client 
> side (Wish version >=8.4.12) with the mouse. Move it
again and again, 
> each time grabbing it and releasing it. After half a
dozen mouse-clicks, 
> the client freezes. Check the MacOS system Console
(Console Utility). 
> There is no error report. The client freezes, but it
does not crash.
> 
> If you quit both the client and server Wish programs,
and repeat the 
> experiment with <=8.4.11 as the client, you'll find
that you can move 
> the windows around as much as you like during data
transfer, and it 
> never freezes. In all cases, you can move the window on
the server side 
> around and it never freezes.
> 
> If you experiment with the getblock procedure, you'll
find that the 
> freeze occurs during "vwait". The freeze
occurs only if the socket is 
> open, free of errors, and data is coming in.
	...


------------------------------------------------------------
-------------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to
make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/
sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Tcl-mac mailing list
tcl-maclists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/tcl-mac
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )