Remove IOLIB-UTILS: will be replaced by ALEXANDRIA.
[iolib.git] / sockets / base-sockets.lisp
blobcad85c28014d77540367fe25cdf0a56c8c1bec29
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 local-address (socket))
46 (defgeneric local-port (socket))
48 (defgeneric remote-name (socket))
50 (defgeneric remote-address (socket))
52 (defgeneric remote-port (socket))
54 (defgeneric get-socket-option (socket option-name))
56 (defgeneric set-socket-option (socket option-name &key &allow-other-keys))
58 (defclass stream-socket (socket) ()
59 (:default-initargs :type :stream))
61 (defclass datagram-socket (socket) ()
62 (:default-initargs :type :datagram))
64 (defgeneric disconnect (socket))
66 (defclass internet-socket (socket) ()
67 (:default-initargs :family (if *ipv6* :ipv6 :ipv4)))
69 (defclass local-socket (socket) ()
70 (:default-initargs :family :local))
72 (defclass active-socket (socket dual-channel-gray-stream) ())
74 (defgeneric connect (socket address &key &allow-other-keys))
76 (defgeneric socket-connected-p (socket))
78 (defgeneric shutdown (socket direction))
80 (defgeneric socket-send (buffer socket &key &allow-other-keys))
82 (defgeneric socket-receive (buffer socket &key &allow-other-keys))
84 (defclass passive-socket (socket)
85 ((listening :initform nil :reader socket-listening-p :type boolean)
86 (external-format :initarg :external-format :reader external-format-of
87 :type external-format)
88 (active-class :initarg :active-class :reader active-class
89 :type symbol :allocation :class))
90 (:default-initargs :external-format :default))
92 (defgeneric bind-address (socket address &key &allow-other-keys))
94 (defgeneric socket-listen (socket &key backlog &allow-other-keys))
96 (defgeneric accept-connection (passive-socket))
98 (defclass socket-stream-internet-active (active-socket stream-socket internet-socket) ())
100 (defclass socket-stream-internet-passive (passive-socket stream-socket internet-socket) ()
101 (:default-initargs :active-class 'socket-stream-internet-active))
103 (defclass socket-stream-local-active (active-socket stream-socket local-socket) ())
105 (defclass socket-stream-local-passive (passive-socket stream-socket local-socket) ()
106 (:default-initargs :active-class 'socket-stream-local-active))
108 (defclass socket-datagram-local-active (active-socket datagram-socket local-socket) ())
110 (defclass socket-datagram-internet-active (active-socket datagram-socket internet-socket) ())