Lisp HUG Maillist Archive

How to terminate operation in LW IDE REPL on Windows

Hi,

I'm trying to test some networking software by listening for messages on socket.
For example I could run with usocket library the following code:

(defun create-server-once  (port)
  (let* ((socket (usocket:socket-connect nil nil
                    :protocol :datagram
                    :element-type '(unsigned-byte 8)
                    :local-host "127.0.0.1"
                    :local-port port))
         (buffer (make-array 8 :element-type '(unsigned-byte 8))))
    (unwind-protect
     (multiple-value-bind (buffer size client receive-port)
         (usocket:socket-receive socket buffer 8)
       (format t "~A~%" buffer))
      (usocket:socket-close socket))))


But when run this code, like (udp-server::create-server-once 10000), I have no option to terminate its execution. The break command is not doing anything, the Debug menu is greyed out and Ctrl-C doesn't help either.
Debugging shows what this function is waiting in mp::process-wait-for-queue.
The way to stop it is either to close the IDE or kill the listener.

How can I terminate it without closing the IDE or killing the listener?

Br,
/Alexey

Re: How to terminate operation in LW IDE REPL on Windows

Hi,

Actually I was mistaken, it was hanging on foreign function
(fli:define-foreign-function (%recvfrom "recvfrom" :source) ...

So it was _not_ mp::process-wait-for-queue, was looking at a wrong callstack.

Still yes the thread solution could work, but maybe some more easy way exist so I don't need to rewrite the simple server code for it?

On Wed, May 17, 2017 at 1:30 PM, Alexey Veretennikov <txm.fourier@gmail.com> wrote:
Hi,

I'm trying to test some networking software by listening for messages on socket.
For example I could run with usocket library the following code:

(defun create-server-once  (port)
  (let* ((socket (usocket:socket-connect nil nil
                    :protocol :datagram
                    :element-type '(unsigned-byte 8)
                    :local-host "127.0.0.1"
                    :local-port port))
         (buffer (make-array 8 :element-type '(unsigned-byte 8))))
    (unwind-protect
     (multiple-value-bind (buffer size client receive-port)
         (usocket:socket-receive socket buffer 8)
       (format t "~A~%" buffer))
      (usocket:socket-close socket))))


But when run this code, like (udp-server::create-server-once 10000), I have no option to terminate its execution. The break command is not doing anything, the Debug menu is greyed out and Ctrl-C doesn't help either.
Debugging shows what this function is waiting in mp::process-wait-for-queue.
The way to stop it is either to close the IDE or kill the listener.

How can I terminate it without closing the IDE or killing the listener?

Br,
/Alexey

Re: How to terminate operation in LW IDE REPL on Windows


On 17 May 2017, at 13:30, Alexey Veretennikov <txm.fourier@gmail.com> wrote:

Hi,

I'm trying to test some networking software by listening for messages on socket.
For example I could run with usocket library the following code:

(defun create-server-once  (port)
  (let* ((socket (usocket:socket-connect nil nil
                    :protocol :datagram
                    :element-type '(unsigned-byte 8)
                    :local-host "127.0.0.1"
                    :local-port port))
         (buffer (make-array 8 :element-type '(unsigned-byte 8))))
    (unwind-protect
     (multiple-value-bind (buffer size client receive-port)
         (usocket:socket-receive socket buffer 8)
       (format t "~A~%" buffer))
      (usocket:socket-close socket))))


But when run this code, like (udp-server::create-server-once 10000), I have no option to terminate its execution. The break command is not doing anything, the Debug menu is greyed out and Ctrl-C doesn't help either.
Debugging shows what this function is waiting in mp::process-wait-for-queue.
The way to stop it is either to close the IDE or kill the listener.

How can I terminate it without closing the IDE or killing the listener?

You could make the socket non-blocking by setting a (short) time-out on it with setsockopt (USOCKET:SOCKET-OPTION).  Then you will have to deal with the various causes for interruption of socket-receive, and possibly loop and retry until you receive your data.


-- 
__Pascal J. Bourguignon__



Updated at: 2020-12-10 08:31 UTC