For this exercise a program is open a socket to localhost on port 256 and send the message "hello socket world" before closing the socket.

Catching any exceptions or errors is not required.




[ | socket |
  [ | addr stream |
    addr: (Net SocketAddress newOn: '127.0.0.1:256').
    socket: (Net Socket newFor: addr domain type: Net Socket Types Stream protocol: Net Socket Protocols Default).
    socket connectTo: addr.
    stream: (Net SocketStream newOn: socket).
    stream nextPutAll: ('hello socket world' as: ByteArray).
    stream flush
  ] ensure: [socket close]
] do.