source: trunk/source/level-1/l1-sockets.lisp

Last change on this file was 16685, checked in by rme, 4 years ago

Update copyright/license headers in files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.5 KB
Line 
1;;;-*- Mode: Lisp; Package: CCL -*-
2;;;
3;;; Copyright 2001-2009 Clozure Associates
4;;;
5;;; Licensed under the Apache License, Version 2.0 (the "License");
6;;; you may not use this file except in compliance with the License.
7;;; You may obtain a copy of the License at
8;;;
9;;;     http://www.apache.org/licenses/LICENSE-2.0
10;;;
11;;; Unless required by applicable law or agreed to in writing, software
12;;; distributed under the License is distributed on an "AS IS" BASIS,
13;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14;;; See the License for the specific language governing permissions and
15;;; limitations under the License.
16
17(in-package "CCL")
18
19(defclass socket ()
20  ())
21
22(defclass ip-socket (socket)
23  ())
24
25(defclass file-socket (socket)
26  ())
27
28(defclass tcp-socket (ip-socket)
29  ())
30
31(defclass stream-file-socket (file-socket)
32  ())
33
34;;; An active TCP socket is an honest-to-goodness stream.
35(defclass tcp-stream (tcp-socket)
36  ())
37
38(defclass fundamental-tcp-stream (tcp-stream
39                                  fd-stream
40                                  buffered-binary-io-stream-mixin
41                                  buffered-character-io-stream-mixin)
42    ())
43
44(make-built-in-class 'basic-tcp-stream
45                     'tcp-stream
46                     'basic-binary-io-stream
47                     'basic-character-io-stream)
48
49;;; A FILE-SOCKET-STREAM is also honest. To goodness.
50(defclass file-socket-stream (stream-file-socket)
51  ())
52
53(defclass fundamental-file-socket-stream (file-socket-stream
54                                          fd-stream
55                                          buffered-binary-io-stream-mixin
56                                          buffered-character-io-stream-mixin)
57    ())
58
59(make-built-in-class 'basic-file-socket-stream
60                     'file-socket-stream
61                     'basic-binary-io-stream
62                     'basic-character-io-stream)
63
64(defclass device-mixin ()
65  ((device :initarg :device :accessor socket-device)
66   (keys :initarg :keys :reader socket-keys)))
67
68;; A passive tcp socket just generates connection streams
69(defclass listener-socket (tcp-socket device-mixin) ())
70
71(defclass file-listener-socket (stream-file-socket device-mixin) ())
72
73;; A udp socket just sends and receives packets.
74(defclass udp-socket (ip-socket device-mixin)
75  ((connected :initarg :connected :initform nil :accessor socket-connected
76              :documentation "True if the socket is connected in the UDP sense,
77              i.e. it has had #_connect successfully called on it.")))
78
79
Note: See TracBrowser for help on using the repository browser.