Create a network service that sits on TCP port 12321, which accepts connections on that port, and which echoes complete lines (using a carriage-return/line-feed sequence as line separator) back to clients. No error handling is required. For the purposes of testing, it is only necessary to support connections from localhost (127.0.0.1 or perhaps ::1). Logging of connection information to standard output is recommended.

The implementation must be able to handle simultaneous connections from multiple clients. A multi-threaded or multi-process solution may be used. Each connection must be able to echo more than a single line.

The implementation must not stop responding to other clients if one client sends a partial line or stops reading responses.

declare
  ServerSocket = {New Open.socket init}
 
  proc {Echo Socket}
     case {Socket getS($)} of false then skip
     [] Line then
        {System.showInfo "Received line: "#Line}
        {Socket write(vs:Line#"\n")}
        {Echo Socket}
     end
  end
 
  class TextSocket from Open.socket Open.text end
in
  {ServerSocket bind(takePort:12321)}
  {System.showInfo "Socket bound."}
 
  {ServerSocket listen}
  {System.showInfo "Started listening."}
 
  for do
     ClientHost ClientPort
     ClientSocket = {ServerSocket accept(accepted:$
					 acceptClass:TextSocket
					 host:?ClientHost
					 port:?ClientPort
					)}
  in
     {System.showInfo "Connection accepted from "#ClientHost#":"#ClientPort#"."}
     thread
        {Echo ClientSocket}
 
	{System.showInfo "Connection lost: "#ClientHost#":"#ClientPort#"."}
        {ClientSocket close}
     end
  end