Author: ehuelsmann
Date: Wed Feb 1 16:00:16 2006
New Revision: 17
Modified:
usocket/trunk/condition.lisp (contents, props changed)
usocket/trunk/doc/design.txt
usocket/trunk/doc/errors.txt
usocket/trunk/package.lisp (contents, props changed)
usocket/trunk/usocket.lisp
Log:
Update with latest condition ideas and API promises.
Modified: usocket/trunk/condition.lisp
==============================================================================
--- usocket/trunk/condition.lisp (original)
+++ usocket/trunk/condition.lisp Wed Feb 1 16:00:16 2006
@@ -1,18 +1,74 @@
;;;; $Id$
-;;;; $Source$
+;;;; $URL$
;;;; See LICENSE for licensing information.
(in-package :usocket)
-(define-condition usocket-error (error)
- ((real-condition
- :reader real-condition
- :initarg :real-condition)
- (socket
- :reader socket
- :initarg :socket))
- (:report (lambda (c stream)
- (format stream "Error (~A) occured in socket: ~A."
- (real-condition c) (socket c)))))
-
+;; (define-condition usocket-error (error)
+;; ((real-condition
+;; :reader real-condition
+;; :initarg :real-condition)
+;; (socket
+;; :reader socket
+;; :initarg :socket))
+;; (:report (lambda (c stream)
+;; (format stream "Error (~A) occured in socket: ~A."
+;; (real-condition c) (socket c)))))
+
+(define-condition usocket-condition (condition)
+ () ;;###FIXME: no slots (yet); should at least be the affected usocket...
+ (:documentation ""))
+
+(define-condition usocket-error (usocket-condition error)
+ () ;; no slots (yet)
+ (:documentation ""))
+
+
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (defun define-usocket-condition-class (class &rest parents)
+ `(progn
+ (define-condition ,class ,parents ())
+ (export ',class))))
+
+(defmacro define-usocket-condition-classes (class-list parents)
+ `(progn ,@(mapcar #'(lambda (x)
+ (apply #'define-usocket-condition-class
+ x parents))
+ class-list)))
+
+;; Mass define and export our conditions
+(define-usocket-condition-classes
+ (usocket-interrupted-condition)
+ (usocket-condition))
+
+(define-condition usocket-unknown-condition (usocket-condition)
+ ((real-condition))
+ (:documentation ""))
+
+
+;; Mass define and export our errors
+(define-usocket-condition-classes
+ (usocket-address-in-use-error
+ usocket-address-not-available-error
+ usocket-bad-file-descriptor-error
+ usocket-connection-refused-error
+ usocket-invalid-argument-error
+ usocket-no-buffers-error
+ usocket-operation-not-supported-error
+ usocket-operation-not-permitted-error
+ usocket-protocol-not-supported-error
+ usocket-socket-type-not-supported-error
+ usocket-network-unreachable-error
+ usocket-network-down-error
+ usocket-network-reset-error
+ usocket-host-down-error
+ usocket-host-unreachable-error
+ usocket-shutdown-error
+ usocket-timeout-error)
+ (usocket-error))
+
+(define-condition usocket-unknown-error (usocket-error)
+ ((real-error))
+ (:documentation ""))
Modified: usocket/trunk/doc/design.txt
==============================================================================
--- usocket/trunk/doc/design.txt (original)
+++ usocket/trunk/doc/design.txt Wed Feb 1 16:00:16 2006
@@ -59,10 +59,19 @@
The interface provided should allow:
- 'client'/active sockets
- 'server'/listening sockets
- - retrieve IP addresses/ports for both sides of the connection
- provide the usual stream methods to operate on the connection stream
(not necessarily the socket itself; maybe a socket slot too)
+For now, as long as there are no possibilities to have UDP sockets
+to write a DNS client library: (which in the end may work better,
+because in this respect all implementations are different...)
+ - retrieve IP addresses/ports for both sides of the connection
+--- later addition
+I don't think it's a good idea to implement name lookup in the
+very first of steps: we'll see if this is required to get the
+package accepted; not all implementations support it.
+--- later addition; end
+
Several relevant support functionalities will have to be provided too:
- long <-> quad-vector operators
- quad-vector <-> string operators
Modified: usocket/trunk/doc/errors.txt
==============================================================================
--- usocket/trunk/doc/errors.txt (original)
+++ usocket/trunk/doc/errors.txt Wed Feb 1 16:00:16 2006
@@ -1,13 +1,20 @@
-EADDRINUSE address-in-use-error
-EAGAIN interrupted-error
-EBADF bad-file-descriptor-error
-ECONNREFUSED connection-refused-error
-EINTR interrupted-error
-EINVAL invalid-argument-error
-ENOBUFS no-buffers-error
-ENOMEM out-of-memory-error
-EOPNOTSUPP operation-not-supported-error
-EPERM operation-not-permitted-error
-EPROTONOSUPPORT protocol-not-supported-error
-ESOCKTNOSUPPORT socket-type-not-supported-error
-ENETUNREACH network-unreachable-error
+EADDRINUSE 48 address-in-use-error
+EADDRNOTAVAIL 49 address-not-available-error
+EAGAIN interrupted-error ;; not 1 error code: bsd == 11; non-bsd == 35
+EBADF 9 bad-file-descriptor-error
+ECONNREFUSED 61 connection-refused-error
+EINTR 4 interrupted-error
+EINVAL 22 invalid-argument-error
+ENOBUFS 55 no-buffers-error
+ENOMEM 12 out-of-memory-error
+EOPNOTSUPP 45 operation-not-supported-error
+EPERM 1 operation-not-permitted-error
+EPROTONOSUPPORT 43 protocol-not-supported-error
+ESOCKTNOSUPPORT 44 socket-type-not-supported-error
+ENETUNREACH 51 network-unreachable-error
+ENETDOWN 50 network-down-error
+ENETRESET 52 network-reset-error
+ESHUTDOWN 58 already-shutdown-error
+ETIMEDOUT 60 connection-timeout-error
+EHOSTDOWN 64 host-down-error
+EHOSTUNREACH 65 host-unreachable-error
Modified: usocket/trunk/package.lisp
==============================================================================
--- usocket/trunk/package.lisp (original)
+++ usocket/trunk/package.lisp Wed Feb 1 16:00:16 2006
@@ -1,5 +1,5 @@
;;;; $Id$
-;;;; $Source$
+;;;; $URL$
;;;; See the LICENSE file for licensing information.
@@ -16,17 +16,14 @@
:usocket ; socket object and accessors
:socket-stream
- :get-host-by-address ; name services
- :get-hosts-by-name
- :get-host-by-name
- :get-random-host-by-name
-
:host-byte-order ; IPv4 utility functions
:hbo-to-dotted-quad
:hbo-to-vector-quad
:vector-quad-to-dotted-quad
:dotted-quad-to-vector-quad
- :usocket-error ; conditions
- :no-route-to-host)))
+ :usocket-condition ; conditions
+ :usocket-error ; errors
+ :usocket-unknown-condition
+ :usocket-unknown-error)))
Modified: usocket/trunk/usocket.lisp
==============================================================================
--- usocket/trunk/usocket.lisp (original)
+++ usocket/trunk/usocket.lisp Wed Feb 1 16:00:16 2006
@@ -5,6 +5,8 @@
(in-package :usocket)
+
+
(defclass usocket ()
((socket
:initarg :socket
@@ -19,14 +21,21 @@
:initarg :local-port
:accessor local-port)))
-(defun make-socket (&key socket local-address local-port stream)
+(defun make-socket (&key socket stream)
(make-instance 'usocket
:socket socket
- :local-address local-address
- :local-port local-port
:stream stream))
-(defgeneric socket-close (usocket))
+(defgeneric socket-close (usocket)
+ (:documentation "Close a previously opened USOCKET."))
+
+(defmacro with-connected-socket ((var socket) &body body)
+ `(let ((,var ,socket))
+ (unwind-protect
+ (progn
+ ,@body)
+ (when ,var
+ (socket-close ,var)))))
;;
;; IPv4 utility functions