SBCL 套接字:重用地址
对 sockopt-reuse-address
的调用似乎没有效果。
(setf socket (make-instance 'sb-bsd-sockets:inet-socket
:type type :protocol protocol)
(setf (sb-bsd-sockets:sockopt-reuse-address socket) t)
(setf (sb-bsd-sockets:non-blocking-mode socket) t)
(sb-bsd-sockets:socket-bind socket ip port)
(sb-bsd-sockets:socket-listen socket backlog)
尝试重新绑定到同一端口会引发以下错误:
Socket error in "bind": EADDRINUSE (Address already in use)
[Condition of type SB-BSD-SOCKETS:ADDRESS-IN-USE-ERROR]
我做错了什么?
The call to sockopt-reuse-address
seems to have no effect.
(setf socket (make-instance 'sb-bsd-sockets:inet-socket
:type type :protocol protocol)
(setf (sb-bsd-sockets:sockopt-reuse-address socket) t)
(setf (sb-bsd-sockets:non-blocking-mode socket) t)
(sb-bsd-sockets:socket-bind socket ip port)
(sb-bsd-sockets:socket-listen socket backlog)
Attempt to rebind to the same port raises the following error:
Socket error in "bind": EADDRINUSE (Address already in use)
[Condition of type SB-BSD-SOCKETS:ADDRESS-IN-USE-ERROR]
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以尝试IOLib,它的
make-socket
功能似乎支持:reuse-address
关键字。据我记得,IOLib 没有利用 Lisp 实现的内置网络功能,因此即使没有 SBCL 直接支持该功能,它也可以工作。不过我还没有测试过。
You could try out IOLib, whose
make-socket
function seems to support a:reuse-address
keyword. As far as I recall, IOLib does not make use of the Lisp implementation's built-in networking functionality, so it might work even without SBCL supporting the feature directly.I haven't tested it, though.
请参阅此帖子在 sbcl-帮助。
See this thread at sbcl-help.