[Pharo-project] [Ocean] Simple client Tcp socket

Noury Bouraqadi bouraqadi at gmail.com
Sat Feb 5 14:58:20 CET 2011


Jannik asked for an example. I thought that it might interest others to test.
So far, it does work only on Mac OS.

1) In a command line terminal evaluate the following
echo "Hello from NetCat" | nc -l 1234

2) Then in a workspace evaluate this code.

serverAddress := OCNIPV4SocketAddress loopbackAddressWithPort:  1234.	
socket := OCNTcpSocket new.
socket isConnected. "---> false"
socket connectToServer: serverAddress.
socket isConnected. "---> true"
socket send: 'Hello from Pharo'.
Transcript cr; show: socket receive.
socket destroy.
socket isConnected. "---> false"

That's all for now,

More information about the Pharo-project mailing list