how to debug socket use
Richard Staehli
rastaehli at mac.com
Tue Apr 20 00:06:04 UTC 2004
Can anyone suggest how to write and debug a very simple use of sockets?
My attempts at writing a remote invocation protocol have been
frustrated by inability to get two squeak processes to talk on the same
machine.
What does work is to start a server (PWS) in process 1, listening on
port 8000, then connecting via a client (Scamper) in process 2.
When I try my code in place of the client, it succeeds in connecting,
and a few times even got replies from the server, but more often it
just hangs, waiting for a reply.
Here's the code:
Transcript show: 'connected to addr: ',addr printString,' port: ',port
printString; cr.
socket sendData: protocolHandler stream contents.
Transcript show: 'done'; cr.
Transcript show: 'QRMIMessage reading... '; cr.
[socket isConnected] whileTrue: [
(socket waitForDataUntil: (Socket deadlineSecs: 5)) ifFalse: [
Transcript show: 'data was late'; cr
].
bytes _ socket receiveDataInto: buf.
Transcript show: 'read:',bytes printString; cr.
1 to: bytes do: [:i | serialization nextPut: (buf at: i)].
totalBytes _ totalBytes + bytes.
].
And here is the typical Transcript output:
connected to addr: a ByteArray(127 0 0 1) port: 8000
done
QuATemplate reading...
data was late
read:0
...
More information about the Squeak-dev
mailing list
|