Changeset 14213


Ignore:
Timestamp:
10/23/12 11:48:44 (8 years ago)
Author:
Mark Evenson
Message:

Implementation of EXT:READ-TIMEOUT for sockets.

Added docstrings for socket API as exported by EXTENSIONS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/socket.lisp

    r14106 r14213  
    3434(export '(make-socket make-server-socket server-socket-close socket-accept
    3535          socket-close get-socket-stream socket-peer-port socket-local-port
    36           socket-local-address socket-peer-address))
     36          socket-local-address socket-peer-address
     37          read-timeout write-timeout))
    3738
    3839
     
    5152
    5253(defun make-socket (host port)
     54  "Create a TCP socket for client communication to HOST on PORT."
    5355  (sys::%make-socket host port))
    5456
    5557(defun make-server-socket (port)
     58  "Create a TCP server socket listening for clients on PORT."
    5659  (sys::%make-server-socket port))
    5760
    5861(defun socket-accept (socket)
     62  "Block until able to return a new socket for handling a incoming request to the specified server SOCKET."
    5963  (sys::%socket-accept socket))
    6064
    6165(defun socket-close (socket)
     66  "Close the client SOCKET."
    6267  (sys::%socket-close socket))
    6368
    6469(defun server-socket-close (socket)
     70  "Close the server SOCKET."
    6571  (sys::%server-socket-close socket))
    6672
    6773(declaim (inline %socket-address %socket-port))
    68 (defun %socket-address (socket addressName)
    69    (java:jcall "getHostAddress" (java:jcall-raw addressName socket)))
     74(defun %socket-address (socket address-name)
     75  "Return the underlying ADDRESS-NAME for SOCKET."
     76   (java:jcall "getHostAddress" (java:jcall-raw address-name socket)))
    7077
    71 (defun %socket-port (socket portName)
    72    (java:jcall portName socket))
     78(defun %socket-port (socket port-name)
     79  "Return the PORT-NAME of SOCKET."
     80   (java:jcall port-name socket))
    7381
    7482(defun socket-local-address (socket)
    75    "Returns the local address of the given socket as a dotted quad string."
     83   "Returns the local address of the SOCKET as a dotted quad string."
    7684   (%socket-address socket "getLocalAddress"))
    7785
    7886(defun socket-peer-address (socket)
    79    "Returns the peer address of the given socket as a dotted quad string."
     87   "Returns the peer address of the SOCKET as a dotted quad string."
    8088   (%socket-address socket "getInetAddress"))
    8189
    8290(defun socket-local-port (socket)
    83    "Returns the local port number of the given socket."
     91   "Returns the local port number of the SOCKET."
    8492   (%socket-port socket "getLocalPort"))
    8593
    8694(defun socket-peer-port (socket)
    87    "Returns the peer port number of the given socket."
     95   "Returns the peer port number of the given SOCKET."
    8896   (%socket-port socket "getPort"))
    8997
     98(defun read-timeout (socket seconds)
     99  "Time in SECONDS to set local implementation of 'SO_RCVTIMEO' on SOCKET."
     100  (java:jcall (java:jmethod "java.net.Socket" "setSoTimeout"  "int")
     101              socket
     102              (/ seconds 1000)))
     103
     104(defun write-timeout (socket seconds)
     105  "No-op setting of write timeout to SECONDS on SOCKET."
     106  (declare (ignore socket seconds))
     107  (warn "Unimplemented.
     108
     109Timeouts for writes should be implemented by spawning a guardian
     110to the thread perfoming the socket write"))
     111
    90112(provide '#:socket)
Note: See TracChangeset for help on using the changeset viewer.