I am working on a TCP client in lisp, and am having difficulties reading/printing the socket-stream correctly. When the client sends data to the server it should receive a response, and I need to write this to stdout. This works correctly, except I am having an issue where the response is printing twice. If I have multiple commands being sent, only the last one will be printed twice. Here is my code:
(defun socket-print (string socket)
(write-line string (usocket:socket-stream socket))
(force-output (usocket:socket-stream socket)))
(defun socket-read (socket)
(write-line (read-line (usocket:socket-stream socket) nil)))
(defun mytest (command)
(let ((socket (usocket:socket-connect _IP_ _PORT_)))
(socket-print command socket)
(socket-read socket)))