Author: ehuelsmann Date: Wed Feb 28 14:29:04 2007 New Revision: 203
Modified: usocket/branches/0.3.x/package.lisp usocket/branches/0.3.x/usocket.lisp Log: Merge r201 and r202 from trunk.
Modified: usocket/branches/0.3.x/package.lisp ============================================================================== --- usocket/branches/0.3.x/package.lisp (original) +++ usocket/branches/0.3.x/package.lisp Wed Feb 28 14:29:04 2007 @@ -21,8 +21,10 @@ #:get-local-name #:get-peer-name
- #:with-connected-socket ; macros + #:with-connected-socket ; convenience macros #:with-server-socket + #:with-client-socket + #:with-socket-listener
#:usocket ; socket object and accessors #:stream-usocket
Modified: usocket/branches/0.3.x/usocket.lisp ============================================================================== --- usocket/branches/0.3.x/usocket.lisp (original) +++ usocket/branches/0.3.x/usocket.lisp Wed Feb 28 14:29:04 2007 @@ -117,15 +117,34 @@ (when ,var (socket-close ,var)))))
+(defmacro with-client-socket ((socket-var stream-var &rest socket-connect-args) + &body body) + "Bind the socket resulting from a call to `socket-connect' with +the arguments `socket-connect-args' to `socket-var' and if `stream-var' is +non-nil, bind the associated socket stream to it." + `(with-connected-socket (,socket-var (socket-connect ,@socket-connect-args)) + ,(if (null stream-var) + `(progn ,@body) + `(let ((,stream-var (socket-stream ,socket-var))) + ,@body)))) + (defmacro with-server-socket ((var server-socket) &body body) "Bind `server-socket' to `var', ensuring socket destruction on exit.
`body' is only evaluated when `var' is bound to a non-null value.
The `body' is an implied progn form." - `(with-connected-socket (var server-socket) + `(with-connected-socket (,var ,server-socket) + ,@body)) + +(defmacro with-socket-listener ((socket-var &rest socket-listen-args) + &body body) + "Bind the socket resulting from a call to `socket-listen' with arguments +`socket-listen-args' to `socket-var'." + `(with-server-socket (,socket-var (socket-listen ,@socket-listen-args)) ,@body))
+ ;; ;; IP(v4) utility functions ;;