[usocket-devel] bind interface?
Chun Tian (binghe)
binghe.lisp at gmail.com
Wed Jul 16 07:27:38 UTC 2008
Hi, Chris Dean
You mean: when you connect to a remote address/port, you also want to
bind to specified local-address/port?
If so, I'm afraid that no such support in usocket yet. The
USOCKET:SOCKET-CONNECT should have additional two keyword parameters
for this feature:
SOCKET-CONNECT (host port &key element-type timeout local-address
local-port)
For LispWorks, following patch can give you what you want (If I guess
right above):
Index: lispworks.lisp
===================================================================
--- lispworks.lisp (revision 362)
+++ lispworks.lisp (working copy)
@@ -73,7 +73,8 @@
(declare (ignore host port err-msg))
(raise-usock-err errno socket condition)))))
-(defun socket-connect (host port &key (element-type 'base-char)
timeout)
+(defun socket-connect (host port &key (element-type 'base-char) timeout
+ local-address local-port)
(when timeout
(warn "SOCKET-CONNECT timeout not supported in Lispworks"))
(let ((hostname (host-to-hostname host))
@@ -81,7 +82,9 @@
(setf stream
(with-mapped-conditions ()
(comm:open-tcp-stream hostname port
- :element-type element-type)))
+ :element-type element-type
+ :local-address local-address
+ :local-port local-port)))
(if stream
(make-stream-socket :socket (comm:socket-stream-socket stream)
:stream stream)
For other platforms I think there're also quite trivial patches. Maybe
Erik should add this support in usocket 0.4.x.
Regards,
Chun Tian (binghe)
>
> I'm new to usocket and would like to bind a socket to a specific
> address. (bind as in http://www.istild.com/man-pages/man2/bind.
> 2.html)
>
> Is there an api for that?
>
> Cheers,
> Chris Dean
> _______________________________________________
> usocket-devel mailing list
> usocket-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/usocket-devel
More information about the usocket-devel
mailing list