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.




 
defmodule Sockets do
  require Logger
 
  def send_message(port, message) do
    {:ok, socket} = :gen_tcp.connect('localhost', port, [])
    :gen_tcp.send(socket, message)
  end
end
 
Sockets.send_message(256, "hello socket world")
 