API CHANGE: ACCEPT-CONNECTION no longer takes WAIT as keyword parameter. To retain...
[iolib.git] / sockets / base-sockets.lisp
blob895c6423674a5d1aba8ed56fc760e7c68c4b45d8
1 ;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*-
3 ;; Copyright (C) 2006, 2007 Stelian Ionescu
4 ;;
5 ;; This code is free software; you can redistribute it and/or
6 ;; modify it under the terms of the version 2.1 of
7 ;; the GNU Lesser General Public License as published by
8 ;; the Free Software Foundation, as clarified by the
9 ;; preamble found here:
10 ;; http://opensource.franz.com/preamble.html
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU Lesser General
18 ;; Public License along with this library; if not, write to the
19 ;; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA
22 (in-package :net.sockets)
24 ;;;;;;;;;;;;;;;
25 ;;; ;;;
26 ;;; Sockets ;;;
27 ;;; ;;;
28 ;;;;;;;;;;;;;;;
30 (defclass socket (dual-channel-single-fd-mixin)
31 ((family :initarg :family :accessor socket-family)
32 (protocol :initarg :protocol :accessor socket-protocol)
33 (bound :initform nil :reader socket-bound-p :type boolean)))
35 (defgeneric socket-fd (socket))
36 (defgeneric (setf socket-fd) (fd socket))
38 (defgeneric socket-type (socket))
40 (defgeneric socket-open-p (socket))
42 (defgeneric local-name (socket))
44 (defgeneric socket-address (socket))
46 (defgeneric socket-port (socket))
48 (defgeneric remote-name (socket))
50 (defgeneric get-socket-option (socket option-name))
52 (defgeneric set-socket-option (socket option-name &key &allow-other-keys))
54 (defclass stream-socket (socket) ()
55 (:default-initargs :type :stream))
57 (defclass datagram-socket (socket) ()
58 (:default-initargs :type :datagram))
60 (defgeneric disconnect (socket))
62 (defclass internet-socket (socket) ()
63 (:default-initargs :family (if *ipv6* :ipv6 :ipv4)))
65 (defclass local-socket (socket) ()
66 (:default-initargs :family :local))
68 (defclass active-socket (socket dual-channel-gray-stream) ())
70 (defgeneric connect (socket address &key &allow-other-keys))
72 (defgeneric socket-connected-p (socket))
74 (defgeneric shutdown (socket direction))
76 (defgeneric socket-send (buffer socket &key &allow-other-keys))
78 (defgeneric socket-receive (buffer socket &key &allow-other-keys))
80 (defclass passive-socket (socket)
81 ((listening :initform nil :reader socket-listening-p :type boolean)
82 (external-format :initarg :external-format :reader external-format-of
83 :type external-format)
84 (active-class :initarg :active-class :reader active-class
85 :type symbol :allocation :class))
86 (:default-initargs :external-format :default))
88 (defgeneric bind-address (socket address &key &allow-other-keys))
90 (defgeneric socket-listen (socket &key backlog &allow-other-keys))
92 (defgeneric accept-connection (passive-socket))
94 (defclass socket-stream-internet-active (active-socket stream-socket internet-socket) ())
96 (defclass socket-stream-internet-passive (passive-socket stream-socket internet-socket) ()
97 (:default-initargs :active-class 'socket-stream-internet-active))
99 (defclass socket-stream-local-active (active-socket stream-socket local-socket) ())
101 (defclass socket-stream-local-passive (passive-socket stream-socket local-socket) ()
102 (:default-initargs :active-class 'socket-stream-local-active))
104 (defclass socket-datagram-local-active (active-socket datagram-socket local-socket) ())
106 (defclass socket-datagram-internet-active (active-socket datagram-socket internet-socket) ())