[Ocean] Simple client Tcp socket

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Ocean] Simple client Tcp socket

Noury Bouraqadi-2
Hi,

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,
Noury