Changeset 12203


Ignore:
Timestamp:
Jun 5, 2009, 6:42:41 PM (10 years ago)
Author:
gz
Message:

r12089 r12105 r12165 from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-1/l1-sockets.lisp

    r12052 r12203  
    608608    (when out-of-band-inline
    609609      (int-setsockopt fd #$SOL_SOCKET #$SO_OOBINLINE 1))
    610     (rlet ((plinger :linger))
     610    (when (eq address-family :internet)
     611      (when (eq type :stream)
     612        (rlet ((plinger :linger))
    611613          (setf (pref plinger :linger.l_onoff) (if linger 1 0)
    612614                (pref plinger :linger.l_linger) (or linger 0))
    613615          (socket-call socket "setsockopt"
    614                        (c_setsockopt fd #$SOL_SOCKET #$SO_LINGER plinger (record-length :linger))))
    615     (when (eq address-family :internet)
     616                       (c_setsockopt fd #$SOL_SOCKET #$SO_LINGER
     617                                     plinger (record-length :linger)))))
    616618      (when nodelay
    617619        (int-setsockopt fd
     
    666668                    local-filename remote-filename sharing basic
    667669                    external-format (auto-close t)
    668                     connect-timeout input-timeout output-timeout deadline)
     670                    connect-timeout input-timeout output-timeout deadline
     671                    fd)
    669672  "Create and return a new socket."
    670673  (declare (dynamic-extent keys))
     
    673676                   local-port local-host backlog class out-of-band-inline
    674677                   local-filename remote-filename sharing basic external-format
    675                    auto-close connect-timeout input-timeout output-timeout deadline))
     678                   auto-close connect-timeout input-timeout output-timeout deadline fd))
    676679  (ecase address-family
    677680    ((:file) (apply #'make-file-socket keys))
     
    680683
    681684
    682 (defun make-udp-socket (&rest keys &aux (fd -1))
     685(defun make-udp-socket (&rest keys &key (fd -1) &allow-other-keys)
    683686  (unwind-protect
    684687    (let (socket)
    685       (setq fd (socket-call nil "socket"
    686                             (c_socket #$AF_INET #$SOCK_DGRAM #$IPPROTO_UDP)))
     688      (when (< fd 0)
     689        (setq fd (socket-call nil "socket"
     690                              (c_socket #$AF_INET #$SOCK_DGRAM #$IPPROTO_UDP))))
    687691      (apply #'set-socket-options fd keys)
    688692      (setq socket (make-instance 'udp-socket
     
    694698      (fd-close fd))))
    695699
    696 (defun make-tcp-socket (&rest keys &key connect &allow-other-keys &aux (fd -1))
     700(defun make-tcp-socket (&rest keys &key connect (fd -1) &allow-other-keys)
    697701  (unwind-protect
    698     (let (socket)
    699       (setq fd (socket-call nil "socket"
    700                             (c_socket #$AF_INET #$SOCK_STREAM #$IPPROTO_TCP)))
    701       (apply #'set-socket-options fd keys)
    702       (setq socket
    703             (ecase connect
    704               ((nil :active) (apply #'make-tcp-stream-socket fd keys))
    705               ((:passive) (apply #'make-tcp-listener-socket fd keys))))
    706       (setq fd -1)
    707       socket)
     702       (let (socket)
     703         (when (< fd 0)
     704           (setq fd (socket-call nil "socket"
     705                                 (c_socket #$AF_INET #$SOCK_STREAM #$IPPROTO_TCP))))
     706         (apply #'set-socket-options fd keys)
     707         (setq socket
     708               (ecase connect
     709                 ((nil :active) (apply #'make-tcp-stream-socket fd keys))
     710                 ((:passive) (apply #'make-tcp-listener-socket fd keys))))
     711         (setq fd -1)
     712         socket)
    708713    (unless (< fd 0)
    709714      (fd-close fd))))
    710715
    711 (defun make-stream-file-socket (&rest keys &key connect &allow-other-keys &aux (fd -1))
     716(defun make-stream-file-socket (&rest keys &key connect (fd -1) &allow-other-keys)
    712717  (unwind-protect
    713     (let (socket)
    714       (setq fd (socket-call nil "socket" (c_socket #$PF_UNIX #$SOCK_STREAM 0)))
    715       (apply #'set-socket-options fd keys)
    716       (setq socket
    717             (ecase connect
    718               ((nil :active) (apply #'make-file-stream-socket fd keys))
    719               ((:passive) (apply #'make-file-listener-socket fd keys))))
    720       (setq fd -1)
    721       socket)
     718       (let (socket)
     719         (when (< fd 0)
     720           (setq fd (socket-call nil "socket" (c_socket #$PF_UNIX #$SOCK_STREAM 0))))
     721         (apply #'set-socket-options fd keys)
     722         (setq socket
     723               (ecase connect
     724                 ((nil :active) (apply #'make-file-stream-socket fd keys))
     725                 ((:passive) (apply #'make-file-listener-socket fd keys))))
     726         (setq fd -1)
     727         socket)
    722728    (unless (< fd 0)
    723729      (fd-close fd))))
Note: See TracChangeset for help on using the changeset viewer.