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.




 
var libsocket = @("lib","socket");
// connect
int socket = libsocket.connect("localhost",256);
// send data
{
   sheet data = (sheet)"hello socket world";
   int datalen = data.size();
   int was = libsocket.send(socket,data,0,datalen);
   // assuming here that all data has been sent (if not, send them in some loop)
}
// close socket
libsocket.close(socket);
 