On 13 Jan 2011, at 22:56, mkobetic@gmail.com wrote:
Can someone get the above going ?
Yes, the following works as expected for me (Pharo 1.1.1 + latest Xtreams + Cog based VM): | input output listener process sync data | data := #uninitialized. sync := Semaphore new. listener := Socket newTCP. listener listenOn: 9999 backlogSize: 10. process := [ [ input := listener waitForAcceptFor: 10. sync signal ] ensure: [ listener close ] ] fork. output := Socket newTCP. output connectToHostNamed: 'localhost' port: 9999. sync wait. [ output sendData: 'Hello!'; close. data := input receiveData. ] ensure: [ output close. input close. process terminate ]. data.
I realize that I deviated from Sven's version by moving the read out of the accept process, but that shouldn't be a problem, or am I missing something ? I'm also wondering if there is a Socket test suite somewhere that already contains tests like the above, that I could mine for examples. I don't see any in the PharoCore1.2 image.
I have encountered strange things when using sockets from different processes, that is why I moved the code in the block. But it should work, and now it does ;-) Sven