Can anyone please help me and show me where I should look if I wanted to see the exact C code implementing the socket primitives (for the Pharo built Cog VMs) ? On 09 Mar 2012, at 16:44, Sven Van Caekenberghe wrote:
Most socket API's allow for the creation of a server socket on the next available port, often by specifying 0 instead of a port. When the socket is bound, one can retrieve the local port and let the client(s) know. I tried to do that in Pharo today, and these steps seem to work, by accepting an incoming connection gives a primitive failed.
Anyone tried this ?
| socket | socket := Socket newTCP. socket listenOn: 0. [ [ Transcript crShow: 'Port is ', socket localPort printString. (socket waitForAcceptFor: 60) ifNotNil: [ :client | | data | data := client receiveDataTimeout: 30. Transcript crShow: 'Received ', data asString. data ifNotNil: [ client sendData: data reverse; close ] ]. ] ensure: [ socket close ] ] fork.
I am running the Pharo Cog VM on Mac OS X using Pharo 1.4.
Thx,
Sven