Hi
I have a small server that uses usocket as a socket library and sbcl as a compiler:
(defun server () (let ((sock (usocket:socket-listen "88.204.87.138" 3690 :backlog 4))) (loop (let ((csock (usocket:socket-accept sock))) (let ((cstream (usocket:socket-stream csock))) (when cstream (loop for line = (read-line cstream nil) while line do (progn (format t "XMPP: ~A~%" line) (cl-irc:privmsg *irc-connection* "#abcd" line)))) (close cstream))))))
After terminating the thread and reevaluating the function, I get the following error:
Socket error in "bind": EADDRINUSE (Address already in use) [Condition of type SB-BSD-SOCKETS:ADDRESS-IN-USE-ERROR]
I also tried to use :reuseaddress t, but that doesn't help. What is the correct way to stop such server and thread?
P.S. One more thing, are there any examples of how can I build multi-thread server using usocket for serving bunch of clients?