Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read blocking forever on local sockets? #79

Open
Ambrevar opened this issue Jun 15, 2023 · 1 comment
Open

read blocking forever on local sockets? #79

Ambrevar opened this issue Jun 15, 2023 · 1 comment

Comments

@Ambrevar
Copy link

When using read-line and write-line it seems to work:

(let ((path "/tmp/foo.socket"))
  (unwind-protect (iolib:with-open-socket (s :address-family :local
                                             :connect :passive
                                             :local-filename (uiop:native-namestring path))
                    (iolib:with-accept-connection (conn s)
                      (values (read-line conn)
                              (progn (write-line "result" conn)))))
    (uiop:delete-file-if-exists path)))


;; Other REPL
(iolib:with-open-socket (s :address-family :local
                           :remote-filename (uiop:native-namestring "/tmp/foo.socket"))
  (write-line "foo" s)
  (finish-output s)
  (read-line s))

Now switch to read and write:

(let ((path "/tmp/foo.socket"))
  (unwind-protect (iolib:with-open-socket (s :address-family :local
                                             :connect :passive
                                             :local-filename (uiop:native-namestring path))
                    (iolib:with-accept-connection (conn s)
                      (values (read conn)
                              (progn (write "result" :stream conn)))))
    (uiop:delete-file-if-exists path)))

;; Other REPL
(iolib:with-open-socket (s :address-family :local
                           :remote-filename (uiop:native-namestring "/tmp/foo.socket"))
  (write "foo" :stream s)
  (finish-output s)
  (read s))

It hangs forever.

Bug?

@aadcg
Copy link

aadcg commented Jul 10, 2024

If the goal is to send a single message from the client to the server over a local socket, then the following seems to work as intended:

;; server
(let ((path "/tmp/foo.socket"))
  (unwind-protect (iolib:with-open-socket (s :address-family :local
                                             :connect :passive
                                             :local-filename path)
                    (iolib:with-accept-connection (connection s)
                      (write (read connection))
                      nil))
    (uiop:delete-file-if-exists path)))
;; client
(iolib:with-open-socket (s :address-family :local
                           :remote-filename "/tmp/foo.socket")
  (write "foo" :stream s)
  nil)

@sionescu I think the issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants