Oscar, This is how I would write it, using first SocketStreams (which is better for most users) and then plain Sockets. This works for me on Pharo 1.2.2 and 1.3. HTH, Sven | serverSocket dataSent dataRead clientStream semaphore | semaphore := Semaphore new. serverSocket := Socket newTCP listenOn: 9191 backlogSize: 5. [ [ | clientSocket serverStream | clientSocket := serverSocket waitForAcceptFor: 10. serverStream := SocketStream on: clientSocket. dataRead := serverStream upToEnd. serverStream close. semaphore signal ] ensure: [ serverSocket close ] ] forkAt: Processor userBackgroundPriority. (Delay forMilliseconds: 100) wait. dataSent := 'Hello there!'. clientStream := SocketStream openConnectionToHostNamed: 'localhost' port: 9191. clientStream nextPutAll: dataSent. clientStream close. semaphore wait. self assert: dataSent = dataRead. dataRead | serverSocket clientSocket dataSent dataRead semaphore | semaphore := Semaphore new. serverSocket := Socket newTCP listenOn: 9191 backlogSize: 5. [ [ | clientConnectionSocket | clientConnectionSocket := serverSocket waitForAcceptFor: 10. dataRead := clientConnectionSocket receiveData. clientConnectionSocket close. semaphore signal ] ensure: [ serverSocket close ] ] forkAt: Processor userBackgroundPriority. (Delay forMilliseconds: 100) wait. dataSent := 'Hello there!'. clientSocket := Socket newTCP connectToHostNamed: 'localhost' port: 9191. clientSocket sendData: dataSent. clientSocket close. semaphore wait. self assert: dataSent = dataRead. dataRead On 21 Apr 2011, at 15:04, Oscar E A Callau wrote:
Thanks all for your comments.
On Apr 21, 2011, at 07:13 , Sven Van Caekenberghe wrote:
I think the problem might be the #listenOn: I use #listenOn:backlogSize: These are using different primitives.
I tested with #listenOn:backlogSize: too, with the same result, error on #waitForAcceptFor: .
Cheers