[armedbear-cvs] r14213 - trunk/abcl/src/org/armedbear/lisp

mevenson at common-lisp.net mevenson at common-lisp.net
Tue Oct 23 11:48:45 UTC 2012


Author: mevenson
Date: Tue Oct 23 04:48:44 2012
New Revision: 14213

Log:
Implementation of EXT:READ-TIMEOUT for sockets.

Added docstrings for socket API as exported by EXTENSIONS.

Modified:
   trunk/abcl/src/org/armedbear/lisp/socket.lisp

Modified: trunk/abcl/src/org/armedbear/lisp/socket.lisp
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/socket.lisp	Sun Oct 21 12:17:45 2012	(r14212)
+++ trunk/abcl/src/org/armedbear/lisp/socket.lisp	Tue Oct 23 04:48:44 2012	(r14213)
@@ -33,7 +33,8 @@
 
 (export '(make-socket make-server-socket server-socket-close socket-accept
           socket-close get-socket-stream socket-peer-port socket-local-port
-          socket-local-address socket-peer-address))
+          socket-local-address socket-peer-address
+          read-timeout write-timeout))
 
 
 (defun get-socket-stream (socket &key (element-type 'character) (external-format :default))
@@ -50,41 +51,62 @@
   (sys::%socket-stream socket element-type external-format))
 
 (defun make-socket (host port)
+  "Create a TCP socket for client communication to HOST on PORT."
   (sys::%make-socket host port))
 
 (defun make-server-socket (port)
+  "Create a TCP server socket listening for clients on PORT."
   (sys::%make-server-socket port))
 
 (defun socket-accept (socket)
+  "Block until able to return a new socket for handling a incoming request to the specified server SOCKET."
   (sys::%socket-accept socket))
 
 (defun socket-close (socket)
+  "Close the client SOCKET."
   (sys::%socket-close socket))
 
 (defun server-socket-close (socket)
+  "Close the server SOCKET."
   (sys::%server-socket-close socket))
 
 (declaim (inline %socket-address %socket-port))
-(defun %socket-address (socket addressName)
-   (java:jcall "getHostAddress" (java:jcall-raw addressName socket)))
-
-(defun %socket-port (socket portName)
-   (java:jcall portName socket))
+(defun %socket-address (socket address-name)
+  "Return the underlying ADDRESS-NAME for SOCKET."
+   (java:jcall "getHostAddress" (java:jcall-raw address-name socket)))
+
+(defun %socket-port (socket port-name)
+  "Return the PORT-NAME of SOCKET."
+   (java:jcall port-name socket))
 
 (defun socket-local-address (socket)
-   "Returns the local address of the given socket as a dotted quad string."
+   "Returns the local address of the SOCKET as a dotted quad string."
    (%socket-address socket "getLocalAddress"))
 
 (defun socket-peer-address (socket)
-   "Returns the peer address of the given socket as a dotted quad string."
+   "Returns the peer address of the SOCKET as a dotted quad string."
    (%socket-address socket "getInetAddress"))
 
 (defun socket-local-port (socket)
-   "Returns the local port number of the given socket."
+   "Returns the local port number of the SOCKET."
    (%socket-port socket "getLocalPort"))
 
 (defun socket-peer-port (socket)
-   "Returns the peer port number of the given socket."
+   "Returns the peer port number of the given SOCKET."
    (%socket-port socket "getPort"))
 
+(defun read-timeout (socket seconds)
+  "Time in SECONDS to set local implementation of 'SO_RCVTIMEO' on SOCKET."
+  (java:jcall (java:jmethod "java.net.Socket" "setSoTimeout"  "int")
+              socket
+              (/ seconds 1000)))
+
+(defun write-timeout (socket seconds)
+  "No-op setting of write timeout to SECONDS on SOCKET."
+  (declare (ignore socket seconds))
+  (warn "Unimplemented.
+
+Timeouts for writes should be implemented by spawning a guardian
+to the thread perfoming the socket write"))
+
 (provide '#:socket)




More information about the armedbear-cvs mailing list