File: design.txt

package info (click to toggle)
acl2 8.0dfsg-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 226,956 kB
  • sloc: lisp: 2,678,900; ansic: 6,101; perl: 5,816; xml: 3,586; cpp: 2,624; ruby: 2,576; makefile: 2,443; sh: 2,312; python: 778; yacc: 764; ml: 763; awk: 260; csh: 186; php: 171; lex: 165; tcl: 44; java: 41; asm: 23; haskell: 17
file content (136 lines) | stat: -rw-r--r-- 3,830 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

                                                        -*- text -*-

$Id$


                  usocket: Universal sockets library
                  ==================================

Contents
========

 * Motivation
 * Design goal
 * Functional requirements
 * Class structure



Motivation
==========

There are 2 other portability sockets packages [that I know of]
out there:

 1) trivial-sockets
 2) acl-compat (which is a *lot* broader, but contains sockets too)

The first misses some functionality which is fundamental when
the requirements stop being 'trivial', such as finding out the
addresses of either side connected to the tcp/ip stream.

The second, being a complete compatibility library for Allegro,
contains much more than only sockets.  Next to that, as the docs
say, is it mainly directed at providing the functionality required
to port portable-allegroserve - meaning it may be (very) incomplete
on some platforms.

So, that's why I decided to inherit Erik Enge's project to build
a library with the intention to provide portability code in only
1 area of programming, targeted at 'not so trivial' programming.

Also, I need this library to extend cl-irc with full DCC functionality.



Design goal
===========

To provide a portable TCP/IP socket interface for as many
implementations as possible, while keeping the portability layer
as thin as possible.



Functional requirements
=======================

The interface provided should allow:
 - 'client'/active sockets
 - 'server'/listening sockets
 - provide the usual stream methods to operate on the connection stream
   (not necessarily the socket itself; maybe a socket slot too)

For now, as long as there are no possibilities to have UDP sockets
to write a DNS client library: (which in the end may work better,
because in this respect all implementations are different...)
 - retrieve IP addresses/ports for both sides of the connection

Several relevant support functionalities will have to be provided too:
 - long <-> quad-vector operators
 - quad-vector <-> string operators
 - hostname <-> quad-vector operators (hostname resolution)


Minimally, I'd like to support:
 - SBCL
 - CMUCL
 - ABCL (ArmedBear)
 - clisp
 - Allegro
 - LispWorks
 - OpenMCL


Comments on the design above
============================

I don't think it's a good idea to implement name lookup in the
very first of steps: we'll see if this is required to get the
package accepted; not all implementations support it.

Name resolution errors ...
Since there is no name resolution library (yet), nor standardized
hooks into the standard C library to do it the same way on
all platforms, name resolution errors can manifest themselves
in a lot of different ways.  How to marshall these to the
library users?

Several solutions come to mind:

1) Map them to 'unknown-error
2) Give them their own errors and map to those
   ... which implies that they are actually supported atm.
3) ...

Given that the library doesn't now, but may in the future,
include name resolution officially, I tend to think (1) is the
right answer: it leaves it all undecided.

These errors can be raised by the nameresolution service
(netdb.h) as values for 'int h_errno':

- HOST_NOT_FOUND (1)
- TRY_AGAIN      (2) /* Server fail or non-authoritive Host not found */
- NO_RECOVERY    (3) /* Failed permanently */
- NO_DATA        (4) /* Valid address, no data for requested record */

int *__h_errno_location(void) points to thread local h_errno on
threaded glibc2 systems.


Class structure
===============

 usocket
  |
  +- datagram-usocket
  +- stream-usocket
  \- stream-server-usocket

The usocket class will have methods to query local properties, such
as:

 - get-local-name: to query to which interface the socket is bound
 - <other socket and protocol options such as SO_REUSEADDRESS>