Forgot to dereference a pointer when returning a socket option.
[iolib.git] / sockets / base-sockets.lisp
blobe6e431c46b2aa20bf74208de6252e74376cbef4b
1 ;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp -*-
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ; Copyright (C) 2006 by Stelian Ionescu ;
5 ; ;
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. ;
10 ; ;
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. ;
15 ; ;
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)))
23 (declaim (optimize (speed 0) (safety 2) (space 0) (debug 2)))
25 (in-package :net.sockets)
27 ;;;;;;;;;;;;;;;
28 ;;; ;;;
29 ;;; Sockets ;;;
30 ;;; ;;;
31 ;;;;;;;;;;;;;;;
33 (defclass socket ()
34 ((fd :reader socket-fd)
35 (family :initarg :family :reader socket-family)
36 (protocol :initarg :protocol :reader socket-protocol)))
38 (defgeneric socket-type (socket))
40 (defgeneric socket-non-blocking-mode (socket))
41 (defgeneric (setf socket-non-blocking-mode) (value socket))
43 (defgeneric socket-close (socket)
44 (:method-combination progn :most-specific-last))
46 (defgeneric socket-open-p (socket))
48 (defgeneric local-name (socket))
50 (defgeneric socket-address (socket))
52 (defgeneric socket-port (socket))
54 (defgeneric remote-name (socket))
56 (defgeneric get-socket-option (socket option-name))
58 (defgeneric set-socket-option (socket option-name &key &allow-other-keys))
60 (defclass stream-socket (socket)
61 ((lisp-stream :reader socket-lisp-stream))
62 (:default-initargs :type :stream))
64 (defclass datagram-socket (socket) ()
65 (:default-initargs :type :datagram))
67 (defgeneric unconnect (socket))
69 (defclass internet-socket (socket) ()
70 (:default-initargs :family (if *ipv6* :ipv6 :ipv4)))
72 (defclass local-socket (socket) ()
73 (:default-initargs :family :local))
75 (defclass active-socket (socket) ())
77 (defgeneric connect (socket address &key &allow-other-keys))
79 (defgeneric socket-connected-p (socket))
81 (defgeneric shutdown (socket direction))
83 (defgeneric socket-send (buffer socket &key &allow-other-keys))
85 (defgeneric socket-receive (buffer socket &key &allow-other-keys))
87 (defclass passive-socket (socket)
88 ((bound :initform nil :reader socket-bound-p :type boolean)
89 (listening :initform nil :reader socket-listening-p :type boolean)
90 (active-class :initarg :active-class :reader active-class
91 :type symbol :allocation :class)))
93 (defgeneric bind-address (socket address &key &allow-other-keys))
95 (defgeneric socket-listen (socket &key backlog &allow-other-keys))
97 (defgeneric accept-connection (passive-socket &key wait &allow-other-keys))
99 (defclass socket-stream-internet-active (active-socket stream-socket internet-socket) ())
101 (defclass socket-stream-internet-passive (passive-socket stream-socket internet-socket) ()
102 (:default-initargs :active-class 'socket-stream-internet-active))
104 (defclass socket-stream-local-active (active-socket stream-socket local-socket) ())
106 (defclass socket-stream-local-passive (passive-socket stream-socket local-socket) ()
107 (:default-initargs :active-class 'socket-stream-local-active))
109 (defclass socket-datagram-local-active (active-socket datagram-socket local-socket) ())
111 (defclass socket-datagram-internet-active (active-socket datagram-socket internet-socket) ())