From ehuelsmann at common-lisp.net Tue Jun 5 15:07:17 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Tue, 5 Jun 2007 11:07:17 -0400 (EDT) Subject: [usocket-cvs] r258 - usocket/trunk Message-ID: <20070605150717.7BAA066004@common-lisp.net> Author: ehuelsmann Date: Tue Jun 5 11:07:16 2007 New Revision: 258 Modified: usocket/trunk/usocket.lisp Log: Fix crash where resolution leads to 'no data'. Return NIL instead. Modified: usocket/trunk/usocket.lisp ============================================================================== --- usocket/trunk/usocket.lisp (original) +++ usocket/trunk/usocket.lisp Tue Jun 5 11:07:16 2007 @@ -296,7 +296,8 @@ (defun get-random-host-by-name (name) (let ((hosts (get-hosts-by-name name))) - (elt hosts (random (length hosts))))) + (when hosts + (elt hosts (random (length hosts)))))) (defun host-to-vector-quad (host) "Translate a host specification (vector quad, dotted quad or domain name) From ehuelsmann at common-lisp.net Tue Jun 5 15:07:59 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Tue, 5 Jun 2007 11:07:59 -0400 (EDT) Subject: [usocket-cvs] r259 - in usocket/trunk: . backend Message-ID: <20070605150759.A26EA74016@common-lisp.net> Author: ehuelsmann Date: Tue Jun 5 11:07:58 2007 New Revision: 259 Modified: usocket/trunk/TODO usocket/trunk/backend/allegro.lisp usocket/trunk/backend/armedbear.lisp usocket/trunk/backend/clisp.lisp usocket/trunk/backend/cmucl.lisp usocket/trunk/backend/lispworks.lisp usocket/trunk/backend/openmcl.lisp usocket/trunk/backend/sbcl.lisp Log: Wrap new wait-for-input code in error handling code. Also update TODO. Modified: usocket/trunk/TODO ============================================================================== --- usocket/trunk/TODO (original) +++ usocket/trunk/TODO Tue Jun 5 11:07:58 2007 @@ -1,4 +1,14 @@ +- Implement wait-for-input-internal for + * SBCL Win32 + * LispWorks Win32 + +- Implement errors for (the alien interface code of) + * SBCL Unix + * CMUCL Unix + * OpenMCL + + - Extend ABCL socket support with the 4 java errors in java.net.* so that they can map to our usocket errors instead of mapping all errors to unknown-error. Modified: usocket/trunk/backend/allegro.lisp ============================================================================== --- usocket/trunk/backend/allegro.lisp (original) +++ usocket/trunk/backend/allegro.lisp Tue Jun 5 11:07:58 2007 @@ -126,16 +126,17 @@ (host-to-hostname name)))))) (defun wait-for-input-internal (sockets &key timeout) - (let ((active-internal-sockets - (if timeout - (mp:wait-for-input-available (mapcar #'socket sockets) - :timeout timeout) - (mp:wait-for-input-available (mapcar #'socket sockets))))) - ;; this is quadratic, but hey, the active-internal-sockets - ;; list is very short and it's only quadratic in the length of that one. - ;; When I have more time I could recode it to something of linear - ;; complexity. - ;; [Same code is also used in lispworks.lisp, openmcl.lisp] - (remove-if #'(lambda (x) - (not (member (socket x) active-internal-sockets))) - sockets))) + (with-mapped-conditions () + (let ((active-internal-sockets + (if timeout + (mp:wait-for-input-available (mapcar #'socket sockets) + :timeout timeout) + (mp:wait-for-input-available (mapcar #'socket sockets))))) + ;; this is quadratic, but hey, the active-internal-sockets + ;; list is very short and it's only quadratic in the length of that one. + ;; When I have more time I could recode it to something of linear + ;; complexity. + ;; [Same code is also used in lispworks.lisp, openmcl.lisp] + (remove-if #'(lambda (x) + (not (member (socket x) active-internal-sockets))) + sockets)))) Modified: usocket/trunk/backend/armedbear.lisp ============================================================================== --- usocket/trunk/backend/armedbear.lisp (original) +++ usocket/trunk/backend/armedbear.lisp Tue Jun 5 11:07:58 2007 @@ -351,8 +351,7 @@ (selector (jdi:do-jstatic "java.nio.channels.Selector" "open")) (channels (mapcar #'socket sockets))) (unwind-protect -;; (with-mapped-conditions () - (progn + (with-mapped-conditions () (let ((jfalse (java:make-immediate-object nil :boolean)) (sel (jdi:jop-deref selector))) (dolist (channel channels) Modified: usocket/trunk/backend/clisp.lisp ============================================================================== --- usocket/trunk/backend/clisp.lisp (original) +++ usocket/trunk/backend/clisp.lisp Tue Jun 5 11:07:58 2007 @@ -126,19 +126,20 @@ (defmethod wait-for-input-internal (sockets &key timeout) - (multiple-value-bind - (secs musecs) - (split-timeout (or timeout 1)) - (let* ((request-list (mapcar #'(lambda (x) - (if (stream-server-usocket-p x) - (socket x) - (list (socket x) :input))) - sockets)) - (status-list (if timeout - (socket:socket-status request-list secs musecs) - (socket:socket-status request-list)))) - (remove nil - (mapcar #'(lambda (x y) - (when y x)) - sockets status-list))))) + (with-mapped-conditions () + (multiple-value-bind + (secs musecs) + (split-timeout (or timeout 1)) + (let* ((request-list (mapcar #'(lambda (x) + (if (stream-server-usocket-p x) + (socket x) + (list (socket x) :input))) + sockets)) + (status-list (if timeout + (socket:socket-status request-list secs musecs) + (socket:socket-status request-list)))) + (remove nil + (mapcar #'(lambda (x y) + (when y x)) + sockets status-list)))))) Modified: usocket/trunk/backend/cmucl.lisp ============================================================================== --- usocket/trunk/backend/cmucl.lisp (original) +++ usocket/trunk/backend/cmucl.lisp Tue Jun 5 11:07:58 2007 @@ -164,24 +164,25 @@ (unix:unix-gethostname)) (defun wait-for-input-internal (sockets &key timeout) - (alien:with-alien ((rfds (alien:struct unix:fd-set))) - (unix:fd-zero rfds) - (dolist (socket sockets) - (unix:fd-set (socket socket) rfds)) - (multiple-value-bind - (secs musecs) - (split-timeout (or timeout 1)) + (with-mapped-conditions () + (alien:with-alien ((rfds (alien:struct unix:fd-set))) + (unix:fd-zero rfds) + (dolist (socket sockets) + (unix:fd-set (socket socket) rfds)) (multiple-value-bind - (count err) - (unix:unix-fast-select (1+ (reduce #'max sockets - :key #'socket)) - (alien:addr rfds) nil nil - (when timeout secs) musecs) - (if (<= 0 count) - ;; process the result... - (remove-if #'(lambda (x) - (not (unix:fd-isset (socket x) rfds))) - sockets) - (progn - ;;###FIXME generate an error, except for EINTR - )))))) + (secs musecs) + (split-timeout (or timeout 1)) + (multiple-value-bind + (count err) + (unix:unix-fast-select (1+ (reduce #'max sockets + :key #'socket)) + (alien:addr rfds) nil nil + (when timeout secs) musecs) + (if (<= 0 count) + ;; process the result... + (remove-if #'(lambda (x) + (not (unix:fd-isset (socket x) rfds))) + sockets) + (progn + ;;###FIXME generate an error, except for EINTR + ))))))) Modified: usocket/trunk/backend/lispworks.lisp ============================================================================== --- usocket/trunk/backend/lispworks.lisp (original) +++ usocket/trunk/backend/lispworks.lisp Tue Jun 5 11:07:58 2007 @@ -150,18 +150,17 @@ #-win32 (defun wait-for-input-internal (sockets &key timeout) - ;; unfortunately, it's impossible to share code between - ;; non-win32 and win32 platforms... - ;; Can we have a sane -pref. complete [UDP!?]- API next time, please? - (mapcar #'mp:notice-fd sockets - :key #'os-socket-handle) - (mp:process-wait-with-timeout "Waiting for a socket to become active" - (truncate timeout) - #'(lambda (socks) - (some #'usocket-listen socks)) - sockets) - (mapcar #'mp:unnotice-fd sockets - :key #'os-socket-handle) - (loop for r in (mapcar #'usocket-listen sockets) - if r - collect r)) + (with-mapped-conditions () + ;; unfortunately, it's impossible to share code between + ;; non-win32 and win32 platforms... + ;; Can we have a sane -pref. complete [UDP!?]- API next time, please? + (mapcar #'mp:notice-fd sockets + :key #'os-socket-handle) + (mp:process-wait-with-timeout "Waiting for a socket to become active" + (truncate timeout) + #'(lambda (socks) + (some #'usocket-listen socks)) + sockets) + (mapcar #'mp:unnotice-fd sockets + :key #'os-socket-handle) + (remove nil (mapcar #'usocket-listen sockets)))) Modified: usocket/trunk/backend/openmcl.lisp ============================================================================== --- usocket/trunk/backend/openmcl.lisp (original) +++ usocket/trunk/backend/openmcl.lisp Tue Jun 5 11:07:58 2007 @@ -144,17 +144,18 @@ (host-to-hostname name)))))) (defun wait-for-input-internal (sockets &key timeout) - (let* ((ticks-timeout (truncate (* (or timeout 1) ccl::*ticks-per-second*))) - (active-internal-sockets - (input-available-p (mapcar #'socket sockets) - (when timeout ticks-timeout)))) - ;; this is quadratic, but hey, the active-internal-sockets - ;; list is very short and it's only quadratic in the length of that one. - ;; When I have more time I could recode it to something of linear - ;; complexity. - ;; [Same code is also used in lispworks.lisp, allegro.lisp] - (remove-if #'(lambda (x) - (not (member (socket x) active-internal-sockets))) - sockets))) + (with-mapped-conditions () + (let* ((ticks-timeout (truncate (* (or timeout 1) ccl::*ticks-per-second*))) + (active-internal-sockets + (input-available-p (mapcar #'socket sockets) + (when timeout ticks-timeout)))) + ;; this is quadratic, but hey, the active-internal-sockets + ;; list is very short and it's only quadratic in the length of that one. + ;; When I have more time I could recode it to something of linear + ;; complexity. + ;; [Same code is also used in lispworks.lisp, allegro.lisp] + (remove-if #'(lambda (x) + (not (member (socket x) active-internal-sockets))) + sockets)))) Modified: usocket/trunk/backend/sbcl.lisp ============================================================================== --- usocket/trunk/backend/sbcl.lisp (original) +++ usocket/trunk/backend/sbcl.lisp Tue Jun 5 11:07:58 2007 @@ -254,34 +254,36 @@ (progn #-win32 (defun wait-for-input-internal (sockets &key timeout) - (sb-alien:with-alien ((rfds (sb-alien:struct sb-unix:fd-set))) - (sb-unix:fd-zero rfds) - (dolist (socket sockets) - (sb-unix:fd-set (sb-bsd-sockets:socket-file-descriptor (socket socket)) - rfds)) - (multiple-value-bind - (secs musecs) - (split-timeout (or timeout 1)) - (multiple-value-bind - (count err) - (sb-unix:unix-fast-select - (1+ (reduce #'max (mapcar #'socket sockets) - :key #'sb-bsd-sockets:socket-file-descriptor)) - (sb-alien:addr rfds) nil nil - (when timeout secs) musecs) - (if (<= 0 count) - ;; process the result... - (remove-if - #'(lambda (x) - (not (sb-unix:fd-isset - (sb-bsd-sockets:socket-file-descriptor (socket x)) - rfds))) - sockets) - (progn - (unless (= err sb-unix:EINTR) - (error (map-errno-error err)))) - ;;###FIXME generate an error, except for EINTR - ))))) + (with-mapped-conditions () + (sb-alien:with-alien ((rfds (sb-alien:struct sb-unix:fd-set))) + (sb-unix:fd-zero rfds) + (dolist (socket sockets) + (sb-unix:fd-set + (sb-bsd-sockets:socket-file-descriptor (socket socket)) + rfds)) + (multiple-value-bind + (secs musecs) + (split-timeout (or timeout 1)) + (multiple-value-bind + (count err) + (sb-unix:unix-fast-select + (1+ (reduce #'max (mapcar #'socket sockets) + :key #'sb-bsd-sockets:socket-file-descriptor)) + (sb-alien:addr rfds) nil nil + (when timeout secs) musecs) + (if (<= 0 count) + ;; process the result... + (remove-if + #'(lambda (x) + (not (sb-unix:fd-isset + (sb-bsd-sockets:socket-file-descriptor (socket x)) + rfds))) + sockets) + (progn + (unless (= err sb-unix:EINTR) + (error (map-errno-error err)))) + ;;###FIXME generate an error, except for EINTR + )))))) #+win32 (warn "wait-for-input not (yet!) supported...") @@ -290,15 +292,17 @@ #+ecl (progn (defun wait-for-input-internal (sockets &key timeout) - (multiple-value-bind - (secs usecs) - (split-timeout (or timeout 1)) - (let* ((sock-fds (mapcar #'sb-bsd-sockets:socket-file-descriptor - (mapcar #'socket sockets))) - (result-fds (read-select sock-fds (when timeout secs) usecs))) - (remove-if #'(lambda (s) - (not (member - (sb-bsd-sockets:socket-file-descriptor (socket s)) - result-fds))) - sockets)))) + (with-mapped-conditions () + (multiple-value-bind + (secs usecs) + (split-timeout (or timeout 1)) + (let* ((sock-fds (mapcar #'sb-bsd-sockets:socket-file-descriptor + (mapcar #'socket sockets))) + (result-fds (read-select sock-fds (when timeout secs) usecs))) + (remove-if #'(lambda (s) + (not + (member + (sb-bsd-sockets:socket-file-descriptor (socket s)) + result-fds))) + sockets))))) ) From ehuelsmann at common-lisp.net Tue Jun 5 15:23:23 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Tue, 5 Jun 2007 11:23:23 -0400 (EDT) Subject: [usocket-cvs] r260 - in usocket/branches/0.3.x: . backend Message-ID: <20070605152323.EC5AD4D048@common-lisp.net> Author: ehuelsmann Date: Tue Jun 5 11:23:20 2007 New Revision: 260 Modified: usocket/branches/0.3.x/backend/allegro.lisp usocket/branches/0.3.x/backend/armedbear.lisp usocket/branches/0.3.x/backend/clisp.lisp usocket/branches/0.3.x/backend/cmucl.lisp usocket/branches/0.3.x/backend/lispworks.lisp usocket/branches/0.3.x/backend/openmcl.lisp usocket/branches/0.3.x/backend/sbcl.lisp usocket/branches/0.3.x/backend/scl.lisp usocket/branches/0.3.x/usocket.lisp Log: Merge r236:245 and r258 (cl-smtp support and minor crash fix). Modified: usocket/branches/0.3.x/backend/allegro.lisp ============================================================================== --- usocket/branches/0.3.x/backend/allegro.lisp (original) +++ usocket/branches/0.3.x/backend/allegro.lisp Tue Jun 5 11:23:20 2007 @@ -6,7 +6,13 @@ (in-package :usocket) (eval-when (:compile-toplevel :load-toplevel :execute) - (require :sock)) + (require :sock) + ;; note: the line below requires ACL 6.2+ + (require :osi)) + +(defun get-host-name () + ;; note: the line below requires ACL 7.0+ to actually *work* on windows + (excl.osi:gethostname)) (defparameter +allegro-identifier-error-map+ '((:address-in-use . address-in-use-error) Modified: usocket/branches/0.3.x/backend/armedbear.lisp ============================================================================== --- usocket/branches/0.3.x/backend/armedbear.lisp (original) +++ usocket/branches/0.3.x/backend/armedbear.lisp Tue Jun 5 11:23:20 2007 @@ -17,6 +17,14 @@ `(java:jnew (java:jconstructor ,class , at arg-spec) , at args)) +(defun get-host-name () + (let ((localAddress (java:jstatic + (java:jmethod "java.net.InetAddress" + "getLocalHost") + (java:jclass "java.net.InetAddress")))) + (java:jcall (java:jmethod "java.net.InetAddress" "getHostName") + localAddress))) + (defun handle-condition (condition &optional socket) (typecase condition (error (error 'unknown-error :socket socket :real-error condition)))) Modified: usocket/branches/0.3.x/backend/clisp.lisp ============================================================================== --- usocket/branches/0.3.x/backend/clisp.lisp (original) +++ usocket/branches/0.3.x/backend/clisp.lisp Tue Jun 5 11:23:20 2007 @@ -6,6 +6,23 @@ (in-package :usocket) +;; utility routine for looking up the current host name +(FFI:DEF-CALL-OUT get-host-name-internal + (:name "gethostname") + (:arguments (name (FFI:C-PTR (FFI:C-ARRAY-MAX ffi:character 256)) + :OUT :ALLOCA) + (len ffi:int)) + #+win32 (:library "WS2_32") + (:return-type ffi:int)) + + +(defun get-host-name () + (multiple-value-bind (retcode name) + (get-host-name-internal) + (when (= retcode 0) + name))) + + #+win32 (defun remap-maybe-for-win32 (z) (mapcar #'(lambda (x) Modified: usocket/branches/0.3.x/backend/cmucl.lisp ============================================================================== --- usocket/branches/0.3.x/backend/cmucl.lisp (original) +++ usocket/branches/0.3.x/backend/cmucl.lisp Tue Jun 5 11:23:20 2007 @@ -160,3 +160,5 @@ (lookup-host-entry name))) (condition (condition) (handle-condition condition)))) +(defun get-host-name () + (unix:unix-gethostname)) Modified: usocket/branches/0.3.x/backend/lispworks.lisp ============================================================================== --- usocket/branches/0.3.x/backend/lispworks.lisp (original) +++ usocket/branches/0.3.x/backend/lispworks.lisp Tue Jun 5 11:23:20 2007 @@ -9,6 +9,22 @@ (require "comm")) #+win32 +(fli:register-module "ws2_32") + +(fli:define-foreign-function (get-host-name-internal "gethostname" :source) + ((return-string (:reference-return (:ef-mb-string :limit 257))) + (namelen :int)) + :lambda-list (&aux (namelen 256) return-string) + :result-type :int + #+win32 :module #+win32 "ws2_32") + +(defun get-host-name () + (multiple-value-bind (retcode name) + (get-host-name-internal) + (when (= 0 retcode) + name))) + +#+win32 (defun remap-maybe-for-win32 (z) (mapcar #'(lambda (x) (cons (mapcar #'(lambda (y) Modified: usocket/branches/0.3.x/backend/openmcl.lisp ============================================================================== --- usocket/branches/0.3.x/backend/openmcl.lisp (original) +++ usocket/branches/0.3.x/backend/openmcl.lisp Tue Jun 5 11:23:20 2007 @@ -5,7 +5,10 @@ (in-package :usocket) - +(defun get-host-name () + (ccl::%stack-block ((resultbuf 256)) + (when (zerop (#_gethostname resultbuf 256)) + (ccl::%get-cstring resultbuf)))) (defparameter +openmcl-error-map+ '((:address-in-use . address-in-use-error) @@ -23,6 +26,35 @@ (:access-denied . operation-not-permitted-error))) +;; we need something which the openmcl implementors 'forgot' to do: +;; wait for more than one socket-or-fd + +(defun input-available-p (sockets &optional ticks-to-wait) + (ccl::rletZ ((tv :timeval)) + (ccl::ticks-to-timeval ticks-to-wait tv) + (ccl::%stack-block ((infds ccl::*fd-set-size*) + (errfds ccl::*fd-set-size*)) + (ccl::fd-zero infds) + (ccl::fd-zero errfds) + (dolist (sock sockets) + (ccl::fd-set (socket-os-fd sock infds)) + (ccl::fd-set (socket-os-fd sock errfds))) + (let* ((res (ccl::syscall syscalls::select + (1+ (apply #'max fds)) + infds (ccl::%null-ptr) errfds + (if ticks-to-wait tv (ccl::%null-ptr))))) + (when (> res 0) + (remove-if #'(lambda (x) + (not (ccl::fd-is-set (socket-os-fd x) infds))) + sockets)))))) + +(defun wait-for-input (sockets &optional ticks-to-wait) + (let ((wait-end (when ticks-to-wait (+ ticks-to-wait (ccl::get-tick-count))))) + (do ((res (input-available-p sockets ticks-to-wait) + (input-available-p sockets ticks-to-wait))) + ((or res (< wait-end (ccl::get-tick-count))) + res)))) + (defun raise-error-from-id (condition-id socket real-condition) (let ((usock-err (cdr (assoc condition-id +openmcl-error-map+)))) (if usock-err Modified: usocket/branches/0.3.x/backend/sbcl.lisp ============================================================================== --- usocket/branches/0.3.x/backend/sbcl.lisp (original) +++ usocket/branches/0.3.x/backend/sbcl.lisp Tue Jun 5 11:23:20 2007 @@ -13,6 +13,49 @@ (eval-when (:compile-toplevel :load-toplevel :execute) (require :sockets)) +#+sbcl +(progn + #-win32 + (defun get-host-name () + (sb-unix:unix-gethostname)) + + ;; we assume winsock has already been loaded, after all, + ;; we already loaded sb-bsd-sockets and sb-alien + #+win32 + (defun get-host-name () + (sb-alien:with-alien ((buf (sb-alien:array sb-alien:char 256))) + (let ((result (sb-alien:alien-funcall + (sb-alien:extern-alien "gethostname" + (sb-alien:function sb-alien:int + (* sb-alien:char) + sb-alien:int)) + (sb-alien:cast buf (* sb-alien:char)) + 256))) + (when (= result 0) + (cast buf sb-alien:c-string)))))) + + +#+ecl +(progn + (ffi:clines + #-:wsock + "#include " + #+:wsock + "#include " + ) + + (defun get-host-name () + (ffi:c-inline + () () t + "{ char buf[256]; + int r = gethostname(&buf,256); + + if (r == 0) + @(return) = make_simple_base_string(&buf); + else + @(return) = Cnil; + }"))) + (defun map-socket-error (sock-err) (map-errno-error (sb-bsd-sockets::socket-error-errno sock-err))) Modified: usocket/branches/0.3.x/backend/scl.lisp ============================================================================== --- usocket/branches/0.3.x/backend/scl.lisp (original) +++ usocket/branches/0.3.x/backend/scl.lisp Tue Jun 5 11:23:20 2007 @@ -129,3 +129,6 @@ (t (error 'ns-unknown-error :host-or-ip name :real-error errno)))))))) + +(defun get-host-name () + (unix:unix-gethostname)) Modified: usocket/branches/0.3.x/usocket.lisp ============================================================================== --- usocket/branches/0.3.x/usocket.lisp (original) +++ usocket/branches/0.3.x/usocket.lisp Tue Jun 5 11:23:20 2007 @@ -248,7 +248,8 @@ (defun get-random-host-by-name (name) (let ((hosts (get-hosts-by-name name))) - (elt hosts (random (length hosts))))) + (when hosts + (elt hosts (random (length hosts)))))) (defun host-to-vector-quad (host) "Translate a host specification (vector quad, dotted quad or domain name) From ehuelsmann at common-lisp.net Tue Jun 5 15:26:52 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Tue, 5 Jun 2007 11:26:52 -0400 (EDT) Subject: [usocket-cvs] r261 - usocket/tags/0.3.3 Message-ID: <20070605152652.20C2363089@common-lisp.net> Author: ehuelsmann Date: Tue Jun 5 11:26:51 2007 New Revision: 261 Added: usocket/tags/0.3.3/ - copied from r260, usocket/branches/0.3.x/ Modified: usocket/tags/0.3.3/usocket.asd Log: Create 0.3.3 tag. Modified: usocket/tags/0.3.3/usocket.asd ============================================================================== --- usocket/branches/0.3.x/usocket.asd (original) +++ usocket/tags/0.3.3/usocket.asd Tue Jun 5 11:26:51 2007 @@ -14,7 +14,7 @@ (defsystem usocket :name "usocket" :author "Erik Enge & Erik Huelsmann" - :version "0.3.3-dev" + :version "0.3.3" :licence "MIT" :description "Universal socket library for Common Lisp" :depends-on (:split-sequence From ehuelsmann at common-lisp.net Tue Jun 5 15:39:39 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Tue, 5 Jun 2007 11:39:39 -0400 (EDT) Subject: [usocket-cvs] r262 - in public_html: . releases Message-ID: <20070605153939.862F07E003@common-lisp.net> Author: ehuelsmann Date: Tue Jun 5 11:39:37 2007 New Revision: 262 Added: public_html/releases/usocket-0.3.3.tar.gz (contents, props changed) public_html/releases/usocket-0.3.3.tar.gz.asc Modified: public_html/index.shtml Log: Publish 0.3.3 Modified: public_html/index.shtml ============================================================================== --- public_html/index.shtml (original) +++ public_html/index.shtml Tue Jun 5 11:39:37 2007 @@ -371,6 +371,10 @@ + + +
Release history
DateReleaseSummary
Jun 05 20070.3.3Fix where host resolution routine was unable to resolve would return + NIL instead of erroring.
Mar 04, 2007 0.3.2 Fixes for many backends related to closing sockets. Added: public_html/releases/usocket-0.3.3.tar.gz ============================================================================== Binary file. No diff available. Added: public_html/releases/usocket-0.3.3.tar.gz.asc ============================================================================== --- (empty file) +++ public_html/releases/usocket-0.3.3.tar.gz.asc Tue Jun 5 11:39:37 2007 @@ -0,0 +1,7 @@ +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQBGZYJqi5O0Epaz9TkRAtxAAJ9eOOH59rC9+5QYFJPSb4TuRV+qpwCeK+hy +vh2uIFfO8VsNnPVxMxS/Ji4= +=ATGT +-----END PGP SIGNATURE----- From ehuelsmann at common-lisp.net Tue Jun 5 15:40:14 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Tue, 5 Jun 2007 11:40:14 -0400 (EDT) Subject: [usocket-cvs] r263 - usocket/branches/0.3.x Message-ID: <20070605154014.A66D7481A7@common-lisp.net> Author: ehuelsmann Date: Tue Jun 5 11:40:14 2007 New Revision: 263 Modified: usocket/branches/0.3.x/usocket.asd Log: Increment development version. Modified: usocket/branches/0.3.x/usocket.asd ============================================================================== --- usocket/branches/0.3.x/usocket.asd (original) +++ usocket/branches/0.3.x/usocket.asd Tue Jun 5 11:40:14 2007 @@ -14,7 +14,7 @@ (defsystem usocket :name "usocket" :author "Erik Enge & Erik Huelsmann" - :version "0.3.3-dev" + :version "0.3.4-dev" :licence "MIT" :description "Universal socket library for Common Lisp" :depends-on (:split-sequence From ehuelsmann at common-lisp.net Tue Jun 5 19:26:53 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Tue, 5 Jun 2007 15:26:53 -0400 (EDT) Subject: [usocket-cvs] r264 - public_html Message-ID: <20070605192653.C49BE671CC@common-lisp.net> Author: ehuelsmann Date: Tue Jun 5 15:26:51 2007 New Revision: 264 Modified: public_html/index.shtml Log: Add index into the page. Modified: public_html/index.shtml ============================================================================== --- public_html/index.shtml (original) +++ public_html/index.shtml Tue Jun 5 15:26:51 2007 @@ -13,7 +13,18 @@

-

Goal

+ + +

Goal

The project wants to provide a portable TCP/IP (and later on maybe UDP) socket interface for as many Common Lisp implementations as @@ -32,11 +43,11 @@

See the feature comparison with trivial-sockets in order to find out which one you should use.

-

Documentation

+

Documentation

See the documentation page for the API description.

-

Supported implementations

+

Supported implementations

Currently these implementations are supported:

@@ -57,7 +68,7 @@ Implementation comparison page.

-

Community

+

Community

This project has started Januari 2006. There isn't much of a community yet, though I'd like there to be one. So, you're invited to join @@ -75,7 +86,7 @@

-

Development

+

Development

Development will at least follow the steps outlined below. Yet to be determined is whether the currently mentioned steps will @@ -355,14 +366,14 @@

-

Interface guarantees

+

Interface guarantees

The interfaces currently published in the :export part of the package definition are guaranteed to stay compatible for the entire 0.x lifecycle. Extention in a backward compatible way is ofcourse valid, as is the addition of new interface functions.

-

Releases

+

Releases

Current release

Releases are uploaded to the releases/ @@ -371,7 +382,7 @@ - + @@ -417,7 +428,7 @@ -

Project history

+

Project history

Long ago the project was conceived and started by Erik Enge in an attempt to factor out all implementation specific sockets code from From ehuelsmann at common-lisp.net Tue Jun 5 21:20:45 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Tue, 5 Jun 2007 17:20:45 -0400 (EDT) Subject: [usocket-cvs] r265 - public_html Message-ID: <20070605212045.9765A4D048@common-lisp.net> Author: ehuelsmann Date: Tue Jun 5 17:20:43 2007 New Revision: 265 Modified: public_html/feature-comparison.shtml public_html/implementation-comparison.shtml public_html/index.shtml Log: Update webpages. Modified: public_html/feature-comparison.shtml ============================================================================== --- public_html/feature-comparison.shtml (original) +++ public_html/feature-comparison.shtml Tue Jun 5 17:20:43 2007 @@ -19,7 +19,8 @@ The latter implements different feature-sets for different backends while the former supplies consistent functionality for all backends.

-
Release history
DateReleaseSummary
Jun 05 2007
Jun 05, 2007 0.3.3 Fix where host resolution routine was unable to resolve would return NIL instead of erroring.
+
+
@@ -29,7 +30,7 @@ - + @@ -67,7 +68,7 @@ - + @@ -105,7 +106,7 @@ - + @@ -133,11 +134,20 @@
Feature In trivial-sockets?In usocket?
ABCLLispWorks OpenMCL SBCL(all)overall
Client side tcp streams:element-type Yes
Server socket creation Binding specific local portYesYes
Binding specific local interfaceYes*
:element-type for created connectionsNoNo Yes
Accepting connections
+

In summary: there are only a very limited number of features you can depend on to work on all platforms supported by trivial-sockets. While usocket doesn't support all features, you can depend on the features to be available.

+
+ +
+Back to Common-lisp.net. +
+ Modified: public_html/implementation-comparison.shtml ============================================================================== --- public_html/implementation-comparison.shtml (original) +++ public_html/implementation-comparison.shtml Tue Jun 5 17:20:43 2007 @@ -48,6 +48,8 @@ Cormannoyesnono (to come)nono +Total #87(+1)4963 + Modified: public_html/index.shtml ============================================================================== --- public_html/index.shtml (original) +++ public_html/index.shtml Tue Jun 5 17:20:43 2007 @@ -40,9 +40,23 @@

If your lisp isn't mentioned in the list below, please feel free to submit a request for it at the mailing list mentioned below.

-

See the feature comparison with +

Comparison to other socket libraries

+ +

Since usocket is effectively the succesor to trivial-sockets, see the + feature comparison with trivial-sockets in order to find out which one you should use.

+

After starting the project, many others turned out to have worked on + something alike, many times as part of a broader project or library. + Some of them were known at the start of this project, others have + been conceived after the usocket project already started. Not all of + them have exactly the same portability goal.

+ +

See the Implementation + comparison page for a comparison of the portability of other + libaries and how that relates to usocket.

+ +

Documentation

See the documentation page for the API description.

@@ -63,11 +77,6 @@
  • Scieneer
  • -

    To see how this list relates to the supported implementations in other -socket libraries, see the -Implementation comparison -page.

    -

    Community

    This project has started Januari 2006. There isn't much of a community From ehuelsmann at common-lisp.net Wed Jun 6 07:11:23 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Wed, 6 Jun 2007 03:11:23 -0400 (EDT) Subject: [usocket-cvs] r266 - public_html Message-ID: <20070606071123.702A47209B@common-lisp.net> Author: ehuelsmann Date: Wed Jun 6 03:11:22 2007 New Revision: 266 Modified: public_html/api-docs.shtml Log: Start a FAQ. Modified: public_html/api-docs.shtml ============================================================================== --- public_html/api-docs.shtml (original) +++ public_html/api-docs.shtml Wed Jun 6 03:11:22 2007 @@ -15,7 +15,13 @@ -

    usocket API documentation

    + + + +

    usocket API documentation

    $Id$
    Work in progress.

    @@ -133,12 +139,41 @@ retrieved from the returned socket by calling get-local-port.

    + +

    How do I ...

    + +
    +
    ... check whether the other end has closed my socket stream? +
    +
    Reading from a stream which has been closed at the remote end + signals an END-OF-FILE condition, meaning that reading from the stream + and detecting that condition is the way to do it. +
    +
    ... check whether reading from a socket stream will block? +
    +
    When you want to check one stream for readiness of input, + call the + listen + function on the stream object associated with the socket. +
    +
    ... wait for input to become available on (at least) one stream (of a set) +
    +
    Currently, that's hard to do efficiently if you want to use releases. + The next minor release (0.4.0) will include this functionality and + for all platforms (except SBCL and LispWorks; both Win32) it's already + available in trunk (svn://common-lisp.net/project/usocket/svn/usocket/trunk). +
    + If you want to use this code you're most welcome and feedback is appreciated. +
    + +
    + +
    Back to Common-lisp.net.
    - From ehuelsmann at common-lisp.net Wed Jun 6 17:42:46 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Wed, 6 Jun 2007 13:42:46 -0400 (EDT) Subject: [usocket-cvs] r267 - public_html Message-ID: <20070606174246.7E8DD65137@common-lisp.net> Author: ehuelsmann Date: Wed Jun 6 13:42:44 2007 New Revision: 267 Modified: public_html/api-docs.shtml Log: Some layout improvements. And extra FAQ info. Modified: public_html/api-docs.shtml ============================================================================== --- public_html/api-docs.shtml (original) +++ public_html/api-docs.shtml Wed Jun 6 13:42:44 2007 @@ -7,11 +7,27 @@ @@ -142,7 +158,7 @@

    How do I ...

    -
    +
    ... check whether the other end has closed my socket stream?
    Reading from a stream which has been closed at the remote end @@ -154,7 +170,11 @@
    When you want to check one stream for readiness of input, call the listen - function on the stream object associated with the socket. + function on the stream object associated with the socket.
    + Example: +
    (listen (usocket:socket-stream your-socket))
    + ==> NIL (if no input is available)
    +
    ... wait for input to become available on (at least) one stream (of a set)
    @@ -163,7 +183,53 @@ for all platforms (except SBCL and LispWorks; both Win32) it's already available in trunk (svn://common-lisp.net/project/usocket/svn/usocket/trunk).
    - If you want to use this code you're most welcome and feedback is appreciated. + If you want to use this code you're most welcome and feedback is appreciated.
    + Example to be used with trunk: +
    (usocket:wait-for-input (list socket1 socket2 socket3) :timeout <your optional timeout value>)
    + ==> list-of-sockets-to-read-from
    + +
    ... convert my existing trivial-sockets based application to usocket? +
    +
    There are actually 3 answers to that question. +
      +
    1. Rewrite your code to keep a usocket object instead of the stream + object returned by trivial-sockets.
    2. +
    3. The quick conversion with the good performance characteristics + (use only when you don't want to use the socket object):
      + Replace all your invocations of +
      +  (trivial-sockets:open-socket-stream ....)
      +
      +with
      +  (usocket:socket-stream (usocket:socket-connect ...))
      +
      + +And replace all invocations of +
      +  (trivial-sockets:socket-accept ...)
      +
      +with
      +  (usocket:socket-stream (usocket:socket-accept ...))
      +
      + +And replace all invocations of +
      +  (trivial-sockets:open-server ...)
      +
      +with
      +  (usocket:socket-listen ...)
      +
    4. +
    5. And the last option which provides a compatible + (but slower, because it uses Gray streams) interface is to use + trivial-usocket.
      + The trivial-usocket package provides a 1-1 mapped interface to + trivial-sockets, but uses Gray streams; that way, it's later possible + to retrieve the socket object from the stream returned and to use that + socket for other usocket operations. Use this approach as a migration + path where you're not rewriting your application at once, but in + small steps. +
    6. +
    From ehuelsmann at common-lisp.net Wed Jun 6 17:46:16 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Wed, 6 Jun 2007 13:46:16 -0400 (EDT) Subject: [usocket-cvs] r268 - public_html Message-ID: <20070606174616.7F2AF671D6@common-lisp.net> Author: ehuelsmann Date: Wed Jun 6 13:46:15 2007 New Revision: 268 Modified: public_html/api-docs.shtml Log: DTD compliance. Modified: public_html/api-docs.shtml ============================================================================== --- public_html/api-docs.shtml (original) +++ public_html/api-docs.shtml Wed Jun 6 13:46:15 2007 @@ -55,9 +55,9 @@
    Specification of a host parameter
    A host parameter may be any one of
      -
    • 32-bit positive integer, -
    • a string containing an IP addres in dotted notation, or -
    • a host name to be resolved through DNS lookup. +
    • 32-bit positive integer,
    • +
    • a string containing an IP addres in dotted notation, or
    • +
    • a host name to be resolved through DNS lookup.
    @@ -65,7 +65,7 @@

    Functions for socket creation and manipulation

    -
    socket-connect host port &key element-type => socket
    +
    socket-connect host port &key element-type => socket

    Creates a tcp (stream) socket to the host and port specified. The return value is @@ -75,7 +75,7 @@ construction of the associated stream.

    -socket-listen host port &key reuse-address backlog element-type => socket
    +socket-listen host port &key reuse-address backlog element-type => socket

    Creates and returns a passive ("server") socket associated with host and port. The object returned is of subtype stream-server-usocket.

    host names a local interface.
    @@ -87,7 +87,7 @@

    -
    socket-accept socket &key element-type => new-socket
    +
    socket-accept socket &key element-type => new-socket

    Creates and returns an active ("connected") stream socket new-socket from the socket passed. The return value is a socket object of class stream-usocket.

    @@ -97,7 +97,7 @@

    -
    socket-close socket
    +
    socket-close socket

    Flushes the stream associated with the socket and closes the socket connection.

    @@ -122,7 +122,7 @@
    usocket
    Slots:
    -
    socket :accessor socket +
    socket :accessor socket

    Used to store sockets as used by the current implementation - may be any of socket handles, socket objects and stream objects

    @@ -130,7 +130,7 @@
    Parent classes: usocket
    Slots:
    -
    stream :accessor socket-stream +
    stream :accessor socket-stream

    Used to store the stream associated with the tcp socket connection.
    When you want to write to the socket stream, use this function.

    @@ -139,7 +139,7 @@
    Parent classes: usocket
    Slots:
    -
    element-type :reader element-type +
    element-type :reader element-type

    Indicates the default element-type to be used when constructing streams off this socket when no element type is specified in the call to socket-accept.

    From ehuelsmann at common-lisp.net Fri Jun 8 21:34:39 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Fri, 8 Jun 2007 17:34:39 -0400 (EDT) Subject: [usocket-cvs] r269 - public_html Message-ID: <20070608213439.673B547189@common-lisp.net> Author: ehuelsmann Date: Fri Jun 8 17:34:38 2007 New Revision: 269 Modified: public_html/feature-comparison.shtml Log: xhtml compliance. Thanks to attila_lendvai. Modified: public_html/feature-comparison.shtml ============================================================================== --- public_html/feature-comparison.shtml (original) +++ public_html/feature-comparison.shtml Fri Jun 8 17:34:38 2007 @@ -20,7 +20,7 @@ the former supplies consistent functionality for all backends.

    - +
    From ehuelsmann at common-lisp.net Fri Jun 8 21:35:34 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Fri, 8 Jun 2007 17:35:34 -0400 (EDT) Subject: [usocket-cvs] r270 - public_html Message-ID: <20070608213534.3A07247195@common-lisp.net> Author: ehuelsmann Date: Fri Jun 8 17:35:33 2007 New Revision: 270 Modified: public_html/feature-comparison.shtml Log: xhtml compliance. another pass. Modified: public_html/feature-comparison.shtml ============================================================================== --- public_html/feature-comparison.shtml (original) +++ public_html/feature-comparison.shtml Fri Jun 8 17:35:33 2007 @@ -21,6 +21,7 @@
    Feature In trivial-sockets?In usocket?
    ABCL
    + @@ -133,6 +134,7 @@ +
    Feature In trivial-sockets?In usocket?
    ABCLNo
    From ehuelsmann at common-lisp.net Fri Jun 8 21:37:00 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Fri, 8 Jun 2007 17:37:00 -0400 (EDT) Subject: [usocket-cvs] r271 - public_html Message-ID: <20070608213700.76E644719B@common-lisp.net> Author: ehuelsmann Date: Fri Jun 8 17:36:59 2007 New Revision: 271 Modified: public_html/feature-comparison.shtml Log: xhtml compliance. another pass. Modified: public_html/feature-comparison.shtml ============================================================================== --- public_html/feature-comparison.shtml (original) +++ public_html/feature-comparison.shtml Fri Jun 8 17:36:59 2007 @@ -66,7 +66,7 @@ Yes No No - + Server socket creation Binding specific local port Yes @@ -82,7 +82,6 @@ Yes No Yes - Selectable backlog length No @@ -94,7 +93,7 @@ Yes No Yes - + reuse-address Yes Yes @@ -105,11 +104,11 @@ Yes No* Yes* - + :element-type for created connections No Yes - + Accepting connections :element-type for created stream Yes @@ -121,7 +120,7 @@ Yes Yes Yes* - + :external-format for created stream No No From ehuelsmann at common-lisp.net Wed Jun 13 18:35:27 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Wed, 13 Jun 2007 14:35:27 -0400 (EDT) Subject: [usocket-cvs] r272 - usocket/trunk/backend Message-ID: <20070613183527.21CEF74371@common-lisp.net> Author: ehuelsmann Date: Wed Jun 13 14:35:26 2007 New Revision: 272 Modified: usocket/trunk/backend/scl.lisp Log: SCL implementation of wait-for-input-internal, submitted by Douglas Crosher. Modified: usocket/trunk/backend/scl.lisp ============================================================================== --- usocket/trunk/backend/scl.lisp (original) +++ usocket/trunk/backend/scl.lisp Wed Jun 13 14:35:26 2007 @@ -132,3 +132,37 @@ (defun get-host-name () (unix:unix-gethostname)) + +(defun wait-for-input-internal (sockets &key timeout) + (let* ((pollfd-size (alien:alien-size (alien:struct unix::pollfd) :bytes)) + (nfds (length sockets)) + (bytes (* nfds pollfd-size))) + (alien:with-bytes (fds-sap bytes) + (do ((sockets sockets (rest sockets)) + (base 0 (+ base 8))) + ((endp sockets)) + (let ((fd (socket (first sockets)))) + (setf (sys:sap-ref-32 fds-sap base) fd) + (setf (sys:sap-ref-16 fds-sap (+ base 4)) unix::pollin))) + (multiple-value-bind (result errno) + (let ((thread:*thread-whostate* "Poll wait") + (timeout (if timeout + (truncate (* timeout 1000)) + -1))) + (declare (inline unix:unix-poll)) + (unix:unix-poll (alien:sap-alien fds-sap + (* (alien:struct unix::pollfd))) + nfds timeout)) + (cond ((not result) + (error "~@" + (unix:get-unix-error-msg errno))) + (t + (do ((sockets sockets (rest sockets)) + (base 0 (+ base 8)) + (ready nil)) + ((endp sockets) + (nreverse ready)) + (let ((flags (sys:sap-ref-16 fds-sap (+ base 6)))) + (unless (zerop (logand flags unix::pollin)) + (push (first sockets) ready)))))))))) + From ehuelsmann at common-lisp.net Thu Jun 14 06:34:22 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Thu, 14 Jun 2007 02:34:22 -0400 (EDT) Subject: [usocket-cvs] r273 - public_html Message-ID: <20070614063422.3D108554BE@common-lisp.net> Author: ehuelsmann Date: Thu Jun 14 02:34:19 2007 New Revision: 273 Modified: public_html/index.shtml Log: Update website. Modified: public_html/index.shtml ============================================================================== --- public_html/index.shtml (original) +++ public_html/index.shtml Thu Jun 14 02:34:19 2007 @@ -316,7 +316,7 @@ WIP DONE DONE - TODO + DONE Implement more uncommon api calls From ehuelsmann at common-lisp.net Sun Jun 24 18:52:30 2007 From: ehuelsmann at common-lisp.net (ehuelsmann at common-lisp.net) Date: Sun, 24 Jun 2007 14:52:30 -0400 (EDT) Subject: [usocket-cvs] r274 - usocket/trunk Message-ID: <20070624185230.F287455356@common-lisp.net> Author: ehuelsmann Date: Sun Jun 24 14:52:30 2007 New Revision: 274 Modified: usocket/trunk/package.lisp Log: Add missing symbols to the export list. Modified: usocket/trunk/package.lisp ============================================================================== --- usocket/trunk/package.lisp (original) +++ usocket/trunk/package.lisp Sun Jun 24 14:52:30 2007 @@ -43,7 +43,11 @@ #:ip/= #:socket-condition ; conditions + #:ns-condition #:socket-error ; errors + #:ns-error #:unknown-condition - #:unknown-error))) + #:ns-unknown-condition + #:unknown-error + #:ns-unknown-error)))