[squeak-dev] Socket>>#waitForDataFor: and #primSocketReceiveDataAvailable

Klaus D. Witzel klaus.witzel at cobss.com
Mon Feb 25 15:07:33 UTC 2008


I'm trying to provoke the Exceptions which Socket>>#waitForDataFor: would  
signal on failure (and test that it does so), to no avail (no, the .image  
isn't locked and the process doesn't hang).

The below runs in both the Squeak 3.9,3.8 final .images with both the  
3.10.2,3.10.6 VMs on win32; the worker process always terminates without  
an exception.

The implementation of #waitForDataFor:  
(#waitForDataFor:ifClosed:ifTimedOut:) looks like #dataAvailable returns  
true but there cannot be any data since nothing was ever sent. *but* after  
closing the client side, the other side's #dataAvailable  
(#primSocketReceiveDataAvailable) returns true ...

Any hint(s) on what's going on (or wrong) will be recognized with  
gratitude.

/Klaus

  | localhost serverSocket sessionSocket clientSocket worker |

  localhost := NetNameResolver localHostAddress.
"warning:" Socket allInstancesDo: [:socket | socket destroy].
  serverSocket := Socket newTCP listenOn: 7680 backlogSize: 1.
  clientSocket := Socket newTCP connectNonBlockingTo: localhost port: 7680.
  sessionSocket := serverSocket waitForAcceptFor: 1.
  worker := [sessionSocket waitForDataFor: 1] fork.
  Processor yield.
  Transcript cr; show: serverSocket statusString, ' [server]';
	cr; show: clientSocket statusString, ' [client]';
	cr; show: sessionSocket statusString, ' [session], dataAvailable: '
		, sessionSocket dataAvailable storeString;
	cr; show: 'worker: ', worker browserPrintString.
  [clientSocket close] on: Exception do: [:ex|].
  Processor yield.
  Transcript cr; show: serverSocket statusString, ' [server]';
	cr; show: clientSocket statusString, ' [client]';
	cr; show: sessionSocket statusString, ' [session], dataAvailable: '
		, sessionSocket dataAvailable storeString;
	cr; show: 'worker: ', worker browserPrintString; cr.
  [sessionSocket destroy] on: Exception do: [:ex|].
  [clientSocket destroy] on: Exception do: [:ex|].
  [serverSocket destroy] on: Exception do: [:ex|]




More information about the Squeak-dev mailing list