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@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/usocket-devel

_______________________________________________
usocket-devel mailing list
usocket-devel@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/usocket-devel

Reply via email to