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.




(ns socket-example
  (:import (java.net Socket)
           (java.io PrintWriter)))
 
(defn send-data [host msg]
  (with-open [sock (Socket. host 256)
              printer (PrintWriter. (.getOutputStream sock))]
    (.println printer msg)))
 
(send-data "localhost" "hello socket world")