8000 `odd number of &KEY arguments` when calling `(usocket:with-client-socket (socket stream #p"/home/user/mysocket" :element-type '(unsigned-byte 8))` · Issue #131 · usocket/usocket · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

odd number of &KEY arguments when calling (usocket:with-client-socket (socket stream #p"/home/user/mysocket" :element-type '(unsigned-byte 8)) #131

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

Open
MIvanchev opened this issue Dec 21, 2024 · 5 comments

Comments

@MIvanchev
Copy link
MIvanchev commented Dec 21, 2024

On SBCL I get the following stack trace:

Backtrace:
  0: (USOCKET::SOCKET-CONNECT-INTERNAL #P"/home/user/mysocket" :PORT :ELEMENT-TYPE (UNSIGNED-BYTE 8)) [more]
  1: (USOCKET:SOCKET-CONNECT #P"/home/user/mysocket" :ELEMENT-TYPE (UNSIGNED-BYTE 8))

It seems the :PORT keyword gets no value. I'm trying to get this to work #110 but without success. Even (usocket:with-client-socket (socket stream #p"/home/user/mysocket)) fails with

Socket error in "setsockopt": EOPNOTSUPP (Operation not supported)
   [Condition of type SB-BSD-SOCKETS:OPERATION-NOT-SUPPORTED-ERROR]

Restarts:
  0: [USE-OTHER-PORT] Use a different port.
  1: [USE-OTHER-HOST] Use a different host.
  2: [RETRY] Retry socket connection.
  3: [RETRY] Retry SLIME REPL evaluation request.
  4: [*ABORT] Return to SLIME's top level.
  5: [ABORT] abort thread (#<THREAD tid=26977 "repl-thread" RUNNING {10010E8003}>)

Backtrace:
  0: (SB-BSD-SOCKETS:SOCKET-ERROR "setsockopt" 95)
  1: ((SETF SB-BSD-SOCKETS:SOCKOPT-TCP-NODELAY) T #<SB-BSD-SOCKETS:LOCAL-SOCKET fd: 15 {100530F123}>)
  2: (USOCKET::SOCKET-CONNECT-INTERNAL #P"/home/user/mysocket" :PORT NIL :PROTOCOL :STREAM :ELEMENT-TYPE CHARACTER :TIMEOUT NIL :CONNECTION-TIMEOUT NIL :READ-TIMEOUT NIL :DEADLINE NIL :NODELAY T :LOCAL..
  3: (USOCKET:SOCKET-CONNECT #P"/home/user/mysocket" NIL)

Please advise.

@zhscn
Copy link
Contributor
zhscn commented Dec 21, 2024

A possible workaround might be:

diff --git a/backend/sbcl.lisp b/backend/sbcl.lisp
index 4330153..88beb32 100644
--- a/backend/sbcl.lisp
+++ b/backend/sbcl.lisp
@@ -482,7 +482,7 @@ happen. Use with care."
               (setf usocket (make-stream-socket :socket socket :stream *dummy-stream*))
               ;; binghe: use SOCKOPT-TCP-NODELAY as internal symbol
               ;;         to pass compilation on ECL without it.
-              (when (and nodelay sockopt-tcp-nodelay-p)
+              (when (and nodelay sockopt-tcp-nodelay-p (not (pathnamep host)))
                 (setf (sb-bsd-sockets::sockopt-tcp-nodelay socket) nodelay))
               (when (or local-host local-port)
                 (sb-bsd-sockets:socket-bind socket

Example:

CL-USER> (create-userver)
#<BT2:THREAD "usocket-server" {7006055BD3}>
CL-USER> (client)
Hello
NIL

@MIvanchev
Copy link
Author

I think a very major issue here is the poor interface of socket-connect which takes an optional and rest arguments (defun socket-connect (host &optional port &rest args) ... so it's impossible to tell what gets mapped where. In this case, the call (USOCKET:SOCKET-CONNECT #P"/home/user/mysocket" :ELEMENT-TYPE (UNSIGNED-BYTE 8)) seems to infer that :element-type is the port which is quite bad.

@zhscn
Copy link
Contributor
zhscn commented Dec 22, 2024

poor interface of socket-connect which takes an optional and rest arguments

Agreed, @binghe how about introducing new interface socket-connect-domain to get rid of this rabbit hole?

@binghe
Copy link
Member
binghe commented Dec 22, 2024

poor interface of socket-connect which takes an optional and rest arguments

Agreed, @binghe how about introducing new interface socket-connect-domain to get rid of this rabbit hole?

Agreed. You are welcome to submit a PR for the new API (and remove the &optional from SOCKET-CONNECT).

binghe added a commit that referenced this issue Dec 27, 2024
For Unix domain socket connections (on SBCL), the PORT is NIL (previously an optional argument)
@binghe
Copy link
Member
binghe commented Dec 27, 2024

With f5beb2b and afc13a3, perhaps all issues mentioned are gone. Testers needed.

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

3 participants
0