1 ;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*-
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ; Copyright (C) 2006 by Stelian Ionescu ;
6 ; This program is free software; you can redistribute it and/or modify ;
7 ; it under the terms of the GNU General Public License as published by ;
8 ; the Free Software Foundation; either version 2 of the License, or ;
9 ; (at your option) any later version. ;
11 ; This program is distributed in the hope that it will be useful, ;
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of ;
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;
14 ; GNU General Public License for more details. ;
16 ; You should have received a copy of the GNU General Public License ;
17 ; along with this program; if not, write to the ;
18 ; Free Software Foundation, Inc., ;
19 ; 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ;
20 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22 (declaim (optimize (speed 2) (safety 2) (space 1) (debug 2)))
24 (in-package #:net.sockets
)
33 ((fd :reader socket-fd
)
34 (address :initarg
:address
:reader socket-address
:type netaddr
)
35 (family :initarg
:family
:reader socket-family
)
36 (protocol :initarg
:protocol
:reader socket-protocol
)))
38 (defgeneric socket-non-blocking-mode
(socket))
39 (defgeneric (setf socket-non-blocking-mode
) (value socket
))
41 (defgeneric socket-close
(socket)
42 (:method-combination progn
:most-specific-last
))
44 (defgeneric socket-open-p
(socket))
46 (defgeneric local-name
(socket))
48 (defgeneric remote-name
(socket))
50 (defgeneric get-socket-option
(socket option-name
&key
))
52 (defgeneric set-socket-option
(socket option-name
&key
))
54 (defclass stream-socket
(socket)
55 ((lisp-stream :reader socket-lisp-stream
))
56 (:default-initargs
:type
:stream
))
58 (defgeneric socket-send
(buffer socket
&key
59 dont-route dont-wait no-signal
60 out-of-band
&allow-other-keys
))
62 (defgeneric socket-receive
(buffer socket
&key
63 out-of-band peek wait-all
64 dont-wait
&allow-other-keys
))
66 (defclass datagram-socket
(socket) ()
67 (:default-initargs
:type
:datagram
))
69 (defgeneric socket-unconnect
(socket))
71 (defclass internet-socket
(socket)
72 ((port :reader port
:type
'(unsigned-byte 16)))
73 (:default-initargs
:family
(if *ipv6
* :ipv6
:ipv4
)))
75 (defclass unix-socket
(socket) ()
76 (:default-initargs
:family
:unix
))
78 (defclass active-socket
(socket) ())
80 (defgeneric socket-connect
(socket address
&key
&allow-other-keys
))
82 (defgeneric socket-shutdown
(socket direction
))
84 (defclass passive-socket
(socket) ())
86 (defgeneric socket-bind-address
(socket address
&key
))
88 (defgeneric socket-listen
(socket &key backlog
))
90 (defgeneric socket-accept-connection
(passive-socket &key wait
))
92 (defclass socket-stream-internet-active
(active-socket stream-socket internet-socket
) ())
94 (defclass socket-stream-internet-passive
(passive-socket stream-socket internet-socket
) ())
96 (defclass socket-datagram-internet-active
(active-socket datagram-socket internet-socket
) ())
98 (defclass socket-datagram-internet-passive
(passive-socket datagram-socket internet-socket
) ())
100 (defclass socket-stream-unix-active
(active-socket stream-socket unix-socket
) ())
102 (defclass socket-stream-unix-passive
(passive-socket stream-socket unix-socket
) ())
104 (defclass socket-datagram-unix-active
(active-socket datagram-socket unix-socket
) ())
106 (defclass socket-datagram-unix-passive
(passive-socket datagram-socket unix-socket
) ())