Listen on a Socket
Often, it is desired to have an action triggered whenever a socket is written to. SocketListener provides a way to attach such an action to a socket.
Create a SocketListener that saves its message.
Get the socket from the listener.
Connect to the server.
Send messages to the listener.
Check the messages received.
Close the sockets.