[usocket-cvs] r8 - in usocket/trunk: . backend doc

ehuelsmann at common-lisp.net ehuelsmann at common-lisp.net
Sun Jan 29 21:51:25 UTC 2006


Author: ehuelsmann
Date: Sun Jan 29 15:51:23 2006
New Revision: 8

Added:
   usocket/trunk/doc/active-sockets-apis.txt
Modified:
   usocket/trunk/backend/sbcl.lisp
   usocket/trunk/doc/design.txt
   usocket/trunk/package.lisp
   usocket/trunk/usocket.asd
   usocket/trunk/usocket.lisp   (contents, props changed)
Log:
Implement the first bit of 'Step 1' in SBCL and at the same time,
start documenting the different implementations wrt that same step.

Modified: usocket/trunk/backend/sbcl.lisp
==============================================================================
--- usocket/trunk/backend/sbcl.lisp	(original)
+++ usocket/trunk/backend/sbcl.lisp	Sun Jan 29 15:51:23 2006
@@ -12,48 +12,33 @@
                       :real-condition condition
                       :socket socket))))
 
-(defun socket-create (&optional (type :stream))
+(defun socket-connect (host port &optional (type :stream))
   "Connect to `host' on `port'.  `host' is assumed to be a string of
 an IP address represented in vector notation, such as #(192 168 1 1).
 `port' is assumed to be an integer.
 
-Returns a socket object."
+Returns a usocket object."
   (let* ((socket (make-instance 'sb-bsd-sockets:inet-socket
                                 :type type :protocol :tcp))
-         (stream (sb-bsd-sockets:socket-make-stream socket)))
-    (make-instance 'usocket :stream stream :socket socket)))
-
-(defmethod socket-bind ((usocket usocket)
-                        &key (local-host "localhost")
-                             (local-port 0)
-                             (reuse-address t))
-  (with-slots (usocket)
-       socket
-;;  (setf (sockopt-reuseaddress socket) reuse-address)
-     (setf socket
-
-(defmethod socket-connect (host port)
+         (stream (sb-bsd-sockets:socket-make-stream socket))
+         (usocket (make-instance 'usocket :stream stream :socket socket)))
     (handler-case (sb-bsd-sockets:socket-connect socket host port)
       (condition (condition) (handle-condition condition usocket)))
     usocket))
 
-(defmethod socket-close ((socket socket))
+(defmethod socket-close ((usocket usocket))
   "Close socket."
-  (handler-case (sb-bsd-sockets:socket-close (real-socket socket))
-    (condition (condition) (handle-condition condition socket))))
+  (handler-case (sb-bsd-sockets:socket-close (socket usocket))
+    (condition (condition) (handle-condition condition usocket))))
 
-(defmethod socket-read-line ((socket socket))
-  (cl:read-line (real-stream socket)))
 
-(defmethod socket-write-sequence ((socket socket) sequence)
-  (cl:write-sequence sequence (real-stream socket)))
 
 (defun get-host-by-address (address)
   (handler-case (sb-bsd-sockets::host-ent-name
                  (sb-bsd-sockets:get-host-by-address address))
     (condition (condition) (handle-condition condition))))
 
-(defun get-host-by-name (name)
+(defun get-hosts-by-name (name)
   (handler-case (sb-bsd-sockets::host-ent-addresses
                  (sb-bsd-sockets:get-host-by-name name))
     (condition (condition) (handle-condition condition))))

Added: usocket/trunk/doc/active-sockets-apis.txt
==============================================================================
--- (empty file)
+++ usocket/trunk/doc/active-sockets-apis.txt	Sun Jan 29 15:51:23 2006
@@ -0,0 +1,19 @@
+                                                          -*- text -*-
+
+A document to summarizing which API's of the different implementations
+are associated with 'Step 1'.
+
+
+SBCL
+====
+
+  sockets:
+  - socket-bind
+  - make-instance 'inet-socket
+  - socket-connect
+  - socket-close
+
+  DNS name resolution:
+  - get-host-by-name
+  - get-host-by-address
+  - host-ent-addresses

Modified: usocket/trunk/doc/design.txt
==============================================================================
--- usocket/trunk/doc/design.txt	(original)
+++ usocket/trunk/doc/design.txt	Sun Jan 29 15:51:23 2006
@@ -76,5 +76,4 @@
  - clisp
  - Allegro
  - LispWorks
-
-
+ - OpenMCL

Modified: usocket/trunk/package.lisp
==============================================================================
--- usocket/trunk/package.lisp	(original)
+++ usocket/trunk/package.lisp	Sun Jan 29 15:51:23 2006
@@ -10,22 +10,23 @@
 (eval-when (:execute :load-toplevel :compile-toplevel)
   (defpackage :usocket
       (:use :cl)
-    (:nicknames :usoc)
-    (:shadowing-import-from "COMMON-LISP" :close
-                  :open
-                  :read-line
-                  :write-sequence)
-    (:export :open ; socket related operations
-             :make-socket 
-             :close
-             :read-line
-             :write-sequence
-             :socket ; socket object and accessors
-             :host
-             :port
+    (:export :socket-connect ; socket constructors and methods
+             :socket-close
+
+             :usocket ; socket object and accessors
+             :socket-stream
+
              :get-host-by-address ; name services
+             :get-hosts-by-name
              :get-host-by-name
-             :host-byte-order ; utility operators
+             :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)))
 

Modified: usocket/trunk/usocket.asd
==============================================================================
--- usocket/trunk/usocket.asd	(original)
+++ usocket/trunk/usocket.asd	Sun Jan 29 15:51:23 2006
@@ -13,12 +13,11 @@
 
 (defsystem usocket
     :name "usocket"
-    :author "Erik Enge"
+    :author "Erik Enge & Erik Huelsmann"
     :version "0.1.0"
     :licence "MIT"
     :description "Universal socket library for Common Lisp"
-    :depends-on #+sbcl (:sb-bsd-sockets :split-sequence)
-                #-sbcl (:split-sequence)
+    :depends-on (#+sbcl :sb-bsd-sockets :split-sequence)
     :components ((:file "package")
                  (:file "usocket"
                         :depends-on ("package"))

Modified: usocket/trunk/usocket.lisp
==============================================================================
--- usocket/trunk/usocket.lisp	(original)
+++ usocket/trunk/usocket.lisp	Sun Jan 29 15:51:23 2006
@@ -1,5 +1,5 @@
 ;;;; $Id$
-;;;; $Source$
+;;;; $URL$
 
 ;;;; See LICENSE for licensing information.
 
@@ -11,7 +11,7 @@
     :accessor socket)
    (stream
     :initarg :stream
-    :accessor stream)
+    :accessor socket-stream)
    (local-address
     :initarg :local-address
     :accessor local-address)
@@ -19,15 +19,17 @@
     :initarg :local-port
     :accessor local-port)))
 
-(defun make-socket (&key socket local-address local-port stream))
+(defun make-socket (&key socket local-address local-port stream)
   (make-instance 'usocket
                  :socket socket
-                 :local-address host
+                 :local-address local-address
                  :local-port local-port
                  :stream stream))
 
+(defgeneric socket-close (usocket))
+
 ;;
-;; Utility
+;; IPv4 utility functions
 ;;
 
 (defun list-of-strings-to-integers (list)
@@ -77,3 +79,15 @@
 3232235777."
   (+ (* (aref vector 0) 256 256 256) (* (aref vector 1) 256 256)
      (* (aref vector 2) 256) (aref vector 3)))
+
+;;
+;; DNS helper functions
+;;
+
+(defun get-host-by-name (name)
+  (let ((hosts (get-hosts-by-name name)))
+    (car hosts)))
+
+(defun get-random-host-by-name (name)
+  (let ((hosts (get-hosts-by-name name)))
+    (elt hosts (random (length hosts)))))



More information about the usocket-cvs mailing list