Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[d48316]: impnotes / rawsock.html Maximize Restore History

Download this file

rawsock.html    169 lines (168 with data), 42.5 kB

  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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>32.14. Raw Socket Access.</title><link rel="stylesheet" href="impnotes.css" type="text/css" /><link rev="made" href="mailto:clisp-list@lists.sourceforge.net" /><meta name="generator" content="DocBook XSL Stylesheets V2005-10-07_10:16_snapshot" /><link rel="start" href="index.html" title="Implementation Notes for GNU CLISP" /><link rel="up" href="ext-modules.html" title="Chapter 32. Extensions Implemented as Modules" /><link rel="prev" href="fastcgi.html" title="32.13. The FastCGI Interface" /><link rel="next" href="wildcard.html" title="32.15. The Wildcard Module" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">32.14. Raw Socket Access.</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="fastcgi.html">Prev</a> </td><th width="60%" align="center">Chapter 32. Extensions Implemented as Modules</th><td width="20%" align="right"> <a accesskey="n" href="wildcard.html">Next</a></td></tr></table><hr /></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="rawsock"></a>32.14. Raw Socket Access.</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="rawsock.html#rawsock-intro">32.14.1. Introduction</a></span></dt><dt><span class="section"><a href="rawsock.html#rawsock-func">32.14.2. Single System Call Functions</a></span></dt><dt><span class="section"><a href="rawsock.html#rawsock-args">32.14.3. Common arguments</a></span></dt><dd><dl><dt><span class="section"><a href="rawsock.html#rawsock-plat-dep-constants">32.14.3.1. Platform-dependent Keywords</a></span></dt></dl></dd><dt><span class="section"><a href="rawsock.html#rawsock-return">32.14.4. Return Values</a></span></dt><dt><span class="section"><a href="rawsock.html#rawsock-not-implemented">32.14.5. Not Implemented</a></span></dt><dt><span class="section"><a href="rawsock.html#rawsock-high-level">32.14.6. High-Level Functions</a></span></dt></dl></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-intro"></a>32.14.1. Introduction</h3></div></div></div><p>This is the raw socket interface, as described in
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/basedefs/sys/socket.h.html">&lt;<code class="filename">sys/socket.h</code>&gt;</a>.
Sockets are represented by their <a href="http://www.lisp.org/HyperSpec/Body/typ_fixnum.html" target="_top"><code class="classname">FIXNUM</code></a> <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap03.html#tag_03_165">file descriptor</a>s.</p><p>When this module is present, <a href="http://www.lisp.org/HyperSpec/Body/var_stfeaturesst.html" target="_top"><code class="varname">*FEATURES*</code></a> contains the
symbol <code class="constant">:RAWSOCK</code>.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a id="rawsock-use-sockets"></a>Try <code class="classname">SOCKET:SOCKET-STREAM</code> first!</h3><p>For most uses of sockets, the facilities described in
<a href="socket.html" title="31.5. Socket Streams">Section 31.5, “Socket Streams”</a> are adequate and much more convenient than these.
You are encouraged to consider <a href="socket.html" title="31.5. Socket Streams"><code class="classname">SOCKET:SOCKET-STREAM</code></a>s and ensure that they
are not adequate for your purposes before you use raw sockets.
</p></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title"><a id="rawsock-not-streams"></a>Do <span class="strong"><strong>not</strong></span> use <code class="function">EXT:MAKE-STREAM</code>!</h3><p>You can turn such a raw socket into a usual lisp <a href="http://www.lisp.org/HyperSpec/Body/syscla_stream.html" target="_top"><code class="classname">STREAM</code></a>
using <a href="stream-dict.html#make-stream" title="21.3.2. Function EXT:MAKE-STREAM"><code class="function">EXT:MAKE-STREAM</code></a>, but you should be <span class="emphasis"><em>extremely</em></span>
careful with such dubious actions! See the <code class="email">&lt;<a href="mailto:clisp-devel@lists.sourceforge.net">clisp-devel@lists.sourceforge.net</a>&gt;</code> (<a href="http://lists.sourceforge.net/lists/listinfo/clisp-devel" target="_top">http://lists.sourceforge.net/lists/listinfo/clisp-devel</a>)
<a href="http://sourceforge.net/mailarchive/message.php?msg_id=7203955" target="_top">mailing list archives</a> for more details.
Note that <a href="stream-dict.html#make-stream" title="21.3.2. Function EXT:MAKE-STREAM"><code class="function">EXT:MAKE-STREAM</code></a> will duplicate the <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap03.html#tag_03_165">file descriptor</a>
(using <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/dup.html"><code class="function">dup</code></a>),
so you <span class="emphasis"><em>still</em></span> have to <a href="http://www.lisp.org/HyperSpec/Body/fun_close.html" target="_top"><code class="function">CLOSE</code></a> the original raw socket.
</p></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-func"></a>32.14.2. Single System Call Functions</h3></div></div></div><p>We implement access to
</p><table class="simplelist" border="0" summary="Simple list"><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/accept.html"><code class="function">accept</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>address</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/bind.html"><code class="function">bind</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>address</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/connect.html"><code class="function">connect</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>address</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getaddrinfo.html"><code class="function">getaddrinfo</code></a> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a>
node service protocol socktype family passive canonname numerichost
numericserv v4mapped all addrconfig)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getnameinfo.html"><code class="function">getnameinfo</code></a> <em class="replaceable"><code>address</code></em>
<a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> nofqdn numerichost namereqd numericserv numericscope
dgram)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getpeername.html"><code class="function">getpeername</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>address</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getsockname.html"><code class="function">getsockname</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>address</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/htonl.html"><code class="function">htonl</code></a> <em class="replaceable"><code>n</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/htons.html"><code class="function">htons</code></a> <em class="replaceable"><code>n</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/ntohl.html"><code class="function">ntohl</code></a> <em class="replaceable"><code>n</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/ntohs.html"><code class="function">ntohs</code></a> <em class="replaceable"><code>n</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/recv.html"><code class="function">recv</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>buffer</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end peek oob waitall)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/recvfrom.html"><code class="function">recvfrom</code></a> <em class="replaceable"><code>socket</code></em>
<em class="replaceable"><code>buffer</code></em> <em class="replaceable"><code>address</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end peek oob waitall)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/recvmsg.html"><code class="function">recvmsg</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>message</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end peek oob waitall)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/send.html"><code class="function">send</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>buffer</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end oob eor)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/sendmsg.html"><code class="function">sendmsg</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>message</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end oob eor)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/sendto.html"><code class="function">sendto</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>buffer</code></em> <em class="replaceable"><code>address</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end oob eor)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/sockatmark.html"><code class="function">sockatmark</code></a>
<em class="replaceable"><code>socket</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/socket.html"><code class="function">socket</code></a>
<em class="replaceable"><code>domain</code></em> <em class="replaceable"><code>type</code></em> <em class="replaceable"><code>protocol</code></em>)</code></td></tr><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/socketpair.html"><code class="function">socketpair</code></a>
<em class="replaceable"><code>domain</code></em> <em class="replaceable"><code>type</code></em> <em class="replaceable"><code>protocol</code></em>)</code></td></tr></table><p>using same-named lisp functions in package
<strong class="package"><span class="quote">RAWSOCK</span></strong>.
Additionally,</p><table class="simplelist" border="0" summary="Simple list"><tr><td><code class="code">(<code class="function">RAWSOCK:SOCK-CLOSE</code> <em class="replaceable"><code>socket</code></em>)</code>
calls <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/close.html"><code class="function">close</code></a>.</td></tr><tr><td><code class="code">(<code class="function">RAWSOCK:SOCK-LISTEN</code> <em class="replaceable"><code>socket</code></em>
<a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a> (<em class="replaceable"><code>backlog</code></em> SOMAXCONN))</code>
calls <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/listen.html"><code class="function">listen</code></a>.</td></tr></table></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-args"></a>32.14.3. Common arguments</h3></div></div></div><div class="toc"><dl><dt><span class="section"><a href="rawsock.html#rawsock-plat-dep-constants">32.14.3.1. Platform-dependent Keywords</a></span></dt></dl></div><div class="variablelist"><a id="rawsock-args-list"></a><dl><dt><span class="term"><span class="type">void*</span> <em class="replaceable"><code>buffer</code></em></span></dt><dd>A <span class="type"><code class="literal">(<a href="http://www.lisp.org/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><code class="classname">UNSIGNED-BYTE</code></a> 8))</code></span>. The vector may be adjustable
and have a fill pointer. Whenever a function accepts a <em class="replaceable"><code>buffer</code></em>
argument, it also accepts <code class="constant">:START</code> and <code class="constant">:END</code> keyword arguments
with the usual meaning and defaults. You do not have to supply the
vector length because Lisp can determine it itself, but, if you want
to, you can use <code class="constant">:END</code> argument for that.
</dd><dt><span class="term"><span class="type">int</span> <em class="replaceable"><code>socket</code></em></span></dt><dd>An <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a> (returned by
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/socketpair.html"><code class="function">socketpair</code></a> or
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/socket.html"><code class="function">socket</code></a>).</dd><dt><span class="term"><span class="type">int</span> <em class="replaceable"><code>family</code></em><br /></span><span class="term"><span class="type">int</span> <em class="replaceable"><code>domain</code></em></span></dt><dd>A <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> (stands for <code class="constant">AF_UNSPEC</code>),
<a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a>, or a platform-specific keyword, e.g.,
<code class="constant">:INET</code> stands for <code class="constant">AF_INET</code>.
</dd><dt><span class="term"><span class="type">int</span> <em class="replaceable"><code>type</code></em></span></dt><dd>A <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> (stands for 0); <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a>; or a
platform-specific keyword, e.g.,
<code class="constant">:DGRAM</code> stands for <code class="constant">SOCK_DGRAM</code>.
</dd><dt><span class="term"><span class="type">int</span> <em class="replaceable"><code>protocol</code></em></span></dt><dd>A <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> (stands for 0); <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a>; a
platform-specific keyword, e.g., <code class="constant">:ETH_P_ARP</code> stands
for <code class="constant">ETH_P_ARP</code>, <code class="constant">:IPPROTO-ICMP</code>
stands for <code class="constant">IPPROTO_ICMP</code>; or a <a href="http://www.lisp.org/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a> (passed
to <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getprotobyname.html"><code class="function">getprotobyname</code></a>).
</dd><dt><span class="term"><span class="type">int</span> <em class="replaceable"><code>flags</code></em></span></dt><dd>This <a href="http://www.eskimo.com/~scs/C-faq/top.html" target="_top"><span><strong class="command">C</strong></span></a> argument corresponds to keyword
arguments to the Lisp functions. E.g., <code class="function">rawsock:send</code>
accepts <code class="constant">:OOB</code> and <code class="constant">EOR</code> arguments,
while <code class="function">rawsock:recv</code> accepts <code class="constant">PEEK</code>,
<code class="constant">OOB</code> and <code class="constant">WAITALL</code>.
</dd><dt><span class="term"><span class="type">struct sockaddr</span> <em class="replaceable"><code>address</code></em></span></dt><dd>A <a href="http://www.lisp.org/HyperSpec/Body/cla_structure-object.html" target="_top"><code class="classname">STRUCTURE-OBJECT</code></a> <span class="type">RAWSOCK:SOCKADDR</span>
returned by
<a href="rawsock.html#make-sockaddr"><code class="function">MAKE-SOCKADDR</code></a>.
You do not need to supply its length because Lisp can determine it itself.
</dd><dt><span class="term"><span class="type">struct msghdr</span> <em class="replaceable"><code>message</code></em></span></dt><dd><p>A <a href="http://www.lisp.org/HyperSpec/Body/cla_structure-object.html" target="_top"><code class="classname">STRUCTURE-OBJECT</code></a> <span class="type">RAWSOCK:MESSAGE</span>
with the following slots:
</p><div class="variablelist"><table border="0"><col align="left" valign="top" /><tbody><tr><td><span class="term">addr</span></td><td>
a <a href="rawsock.html#make-sockaddr"><span class="type">SOCKADDR</span></a>.
</td></tr><tr><td><span class="term">iovec</span></td><td>
a <span class="type"><code class="literal">(<a href="http://www.lisp.org/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> <span class="type"><code class="literal">(<a href="http://www.lisp.org/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><code class="classname">UNSIGNED-BYTE</code></a> 8))</code></span>)</code></span>
(<code class="constant">:START</code> and <code class="constant">:END</code> arguments are applied to this vector)
</td></tr><tr><td><span class="term">control</span></td><td>
a <span class="type"><code class="literal">(<a href="http://www.lisp.org/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><code class="classname">UNSIGNED-BYTE</code></a> 8))</code></span></td></tr><tr><td><span class="term">flags</span></td><td>
a <a href="http://www.lisp.org/HyperSpec/Body/syscla_list.html" target="_top"><code class="classname">LIST</code></a></td></tr></tbody></table></div></dd></dl></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h4 class="title"><a id="rawsock-plat-dep-constants"></a>32.14.3.1. Platform-dependent Keywords</h4></div></div></div><p>One can extract the list of acceptable platform-dependent
keywords for, e.g., socket domain, using the following code:
</p><pre class="programlisting">
(<a href="http://www.lisp.org/HyperSpec/Body/speope_block.html" target="_top"><code class="function">BLOCK</code></a> <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>
(<a href="http://www.lisp.org/HyperSpec/Body/mac_handler-bind.html" target="_top"><code class="function">HANDLER-BIND</code></a> ((<a href="http://www.lisp.org/HyperSpec/Body/contyp_type-error.html" target="_top"><code class="classname">TYPE-ERROR</code></a>
(<a href="http://www.lisp.org/HyperSpec/Body/mac_lambda.html" target="_top"><code class="function">LAMBDA</code></a> (c)
(<a href="http://www.lisp.org/HyperSpec/Body/fun_format.html" target="_top"><code class="function">FORMAT</code></a> <a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a> "~&amp;error: ~A~%" c)
(<a href="http://www.lisp.org/HyperSpec/Body/mac_return.html" target="_top"><code class="function">RETURN</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/acc_carcm_cdr_darcm_cddddr.html" target="_top"><code class="function">CDDR</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/acc_firstcm_s_inthcm_tenth.html" target="_top"><code class="function">THIRD</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/fun_type-erro_xpected-type.html" target="_top"><code class="function">TYPE-ERROR-EXPECTED-TYPE</code></a> c)))))))
(rawsock:socket "bad" <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>)))
</pre></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-return"></a>32.14.4. Return Values</h3></div></div></div><p>The return values of the functions described in section
<a href="rawsock.html#rawsock-func" title="32.14.2. Single System Call Functions">Section 32.14.2, “Single System Call Functions”</a> are derived from the return values of
the underlying system call: if, say, the <em class="replaceable"><code>address</code></em> argument is modified
by the system call, two values are returned (in addition to the
possible values coming from the return value of the system call):
the (modified) <em class="replaceable"><code>address</code></em> structure and its new size.
If the system call fails, an <a href="http://www.lisp.org/HyperSpec/Body/contyp_error.html" target="_top"><code class="classname">ERROR</code></a> is <a href="http://www.lisp.org/HyperSpec/Body/fun_signal.html" target="_top"><code class="function">SIGNAL</code></a>ed.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-not-implemented"></a>32.14.5. Not Implemented</h3></div></div></div><p>We do not interface to <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/select.html"><code class="function">select</code></a>
or <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/poll.html"><code class="function">poll</code></a> in this module,
they are already available through <a href="socket.html#so-status"><code class="function">SOCKET:SOCKET-STATUS</code></a>.</p><p>We do not interface to <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/shutdown.html"><code class="function">shutdown</code></a>
in this module, it is already available through <a href="socket.html#sost-shut"><code class="function">SOCKET:SOCKET-STREAM-SHUTDOWN</code></a>.</p><p>We do not interface to <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/gethostbyname.html"><code class="function">gethostbyname</code></a>
or <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/gethostbyaddr.html"><code class="function">gethostbyaddr</code></a> in this module,
they are already available through <a href="syscalls.html#resolve-host"><code class="function">POSIX:RESOLVE-HOST-IPADDR</code></a>.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-high-level"></a>32.14.6. High-Level Functions</h3></div></div></div><div class="variablelist"><a id="rawsock-high-level-list"></a><p class="title"><b>Functions that do not
correspond to a single system call</b></p><dl><dt><span class="term"><code class="code">(<code class="function">RAWSOCK:SOCK-READ</code>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>buffer</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code><br /></span><span class="term"><code class="code">(<code class="function">RAWSOCK:SOCK-WRITE</code>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>buffer</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code></span></dt><dd><p>Call one of
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/read.html"><code class="function">read</code></a>/<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/readv.html"><code class="function">readv</code></a> or
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/write.html"><code class="function">write</code></a>/<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/writev.html"><code class="function">writev</code></a>
(depending on whether <em class="replaceable"><code>buffer</code></em> is a <span class="type"><code class="literal">(<a href="http://www.lisp.org/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><code class="classname">UNSIGNED-BYTE</code></a> 8))</code></span> or
a <span class="type"><code class="literal">(<a href="http://www.lisp.org/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> <span class="type"><code class="literal">(<a href="http://www.lisp.org/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><code class="classname">UNSIGNED-BYTE</code></a> 8))</code></span>)</code></span>).
Return the number of bytes read or written.</p><p>When <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/readv.html"><code class="function">readv</code></a> and
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/writev.html"><code class="function">writev</code></a> and not available, they are
emulated by repeated calls to <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/read.html"><code class="function">read</code></a>
and <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/write.html"><code class="function">write</code></a>.</p><p>On <a href="http://winehq.com/" target="_top"><span class="strong"><strong>Win32</strong></span></a> we have to use <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/recv.html"><code class="function">recv</code></a>
instead of <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/read.html"><code class="function">read</code></a>
and <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/send.html"><code class="function">send</code></a> instead of
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/write.html"><code class="function">write</code></a> because <a href="http://winehq.com/" target="_top"><span class="strong"><strong>Win32</strong></span></a>
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/read.html"><code class="function">read</code></a> and
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/write.html"><code class="function">write</code></a> do not work on sockets, only
on regular files.</p></dd><dt><span class="term"><code class="code">(RAWSOCK:PROTOCOL <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a>
<em class="replaceable"><code>protocol</code></em>)</code></span></dt><dd>Call <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getprotobyname.html"><code class="function">getprotobyname</code></a>
when <em class="replaceable"><code>protocol</code></em> is a <a href="http://www.lisp.org/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a>,
or call <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getprotobynumber.html"><code class="function">getprotobynumber</code></a> when
<em class="replaceable"><code>protocol</code></em> is an <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a>.
Return a <span class="type">RAWSOCK:PROTOCOL</span> structure object.
When <em class="replaceable"><code>protocol</code></em> is <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>, return a <a href="http://www.lisp.org/HyperSpec/Body/syscla_list.html" target="_top"><code class="classname">LIST</code></a> of all known protocols using
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/setprotoent.html"><code class="function">setprotoent</code></a>,
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getprotoent.html"><code class="function">getprotoent</code></a>, and
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/endprotoent.html"><code class="function">endprotoent</code></a>.
</dd><dt><span class="term"><code class="code">(RAWSOCK:NETWORK <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a>
<em class="replaceable"><code>network</code></em> <em class="replaceable"><code>type</code></em>)</code></span></dt><dd>Call <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getnetbyname.html"><code class="function">getnetbyname</code></a>
when <em class="replaceable"><code>network</code></em> is a <a href="http://www.lisp.org/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a>,
or call <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getnetbynumber.html"><code class="function">getnetbynumber</code></a> when
<em class="replaceable"><code>network</code></em> is an <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a>.
Return a <span class="type">RAWSOCK:NETWORK</span> structure object.
When <em class="replaceable"><code>network</code></em> is <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>, return a <a href="http://www.lisp.org/HyperSpec/Body/syscla_list.html" target="_top"><code class="classname">LIST</code></a>
of all known networks using <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/setnetent.html"><code class="function">setnetent</code></a>,
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getnetent.html"><code class="function">getnetent</code></a>, and
<a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/endnetent.html"><code class="function">endnetent</code></a>.
</dd><dt><span class="term"><code class="code">(RAWSOCK:SOCKET-OPTION <em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>name</code></em>
<a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> :LEVEL)</code><br /></span><span class="term"><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (RAWSOCK:SOCKET-OPTION <em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>name</code></em>
<a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> :LEVEL) <em class="replaceable"><code>value</code></em>)</code></span></dt><dd>Call <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/getsockopt.html"><code class="function">getsockopt</code></a>
and <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/setsockopt.html"><code class="function">setsockopt</code></a>, returns and sets
individual (for specific option <em class="replaceable"><code>name</code></em> and
<em class="replaceable"><code>level</code></em>) and multiple (when <em class="replaceable"><code>name</code></em> is
<a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> and/or <em class="replaceable"><code>level</code></em> is <code class="constant">:ALL</code>) options.
(See also <a href="socket.html#so-opt"><code class="function">SOCKET:SOCKET-OPTIONS</code></a>.)</dd><dt><span class="term"><code class="code">(RAWSOCK:CONVERT-ADDRESS
<em class="replaceable"><code>family</code></em> <em class="replaceable"><code>address</code></em>)</code></span></dt><dd><p>Convert between <a href="http://www.lisp.org/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a> and <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a> IP
<em class="replaceable"><code>address</code></em> representations using</p><table class="simplelist" border="0" summary="Simple list"><tr><td><a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/inet_addr.html"><code class="function">inet_addr</code></a></td><td><a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/inet_ntop.html"><code class="function">inet_ntop</code></a></td></tr><tr><td><a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/inet_ntoa.html"><code class="function">inet_ntoa</code></a></td><td><a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/inet_pton.html"><code class="function">inet_pton</code></a></td></tr></table></dd><dt><a id="make-sockaddr"></a><span class="term"><code class="code">(RAWSOCK:MAKE-SOCKADDR
<em class="replaceable"><code>family</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a> <em class="replaceable"><code>data</code></em>)</code></span></dt><dd>Create a <span class="type">sockaddr</span> object.
<em class="replaceable"><code>data</code></em> should be a sequence of <span class="type"><code class="literal">(<a href="http://www.lisp.org/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><code class="classname">UNSIGNED-BYTE</code></a> 8)</code></span> or an <a href="http://www.lisp.org/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a>
(meaning <code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/fun_make-list.html" target="_top"><code class="function">MAKE-LIST</code></a> <em class="replaceable"><code>data</code></em> :initial-element 0)</code>).
When omitted, the standard platform-specific size is used.
</dd><dt><span class="term"><code class="code">(RAWSOCK:SOCKADDR-FAMILY <em class="replaceable"><code>address</code></em>)</code></span></dt><dd>Return the numeric family of the
<span class="type">sockaddr</span> object.</dd><dt><span class="term"><code class="code">(RAWSOCK:SOCKADDR-DATA <em class="replaceable"><code>address</code></em>)</code></span></dt><dd><p>Return a <a href="http://www.lisp.org/HyperSpec/Body/glo_f.html#fresh" target="_top">fresh</a> <a href="http://www.lisp.org/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> displaced to the
<em class="structfield"><code>data</code></em> field of the
<a href="http://www.eskimo.com/~scs/C-faq/top.html" target="_top"><span><strong class="command">C</strong></span></a> <span class="type">struct sockaddr</span> object.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>Modifying this <a href="http://www.lisp.org/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a>'s content will modify the
<em class="replaceable"><code>address</code></em> argument data!</p></div></dd><dt><span class="term"><code class="code">(RAWSOCK:OPEN-UNIX-SOCKET
<em class="replaceable"><code>pathname</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a> <em class="replaceable"><code>type</code></em>)</code></span></dt><dd>Open a <a href="http://www.UNIX-systems.org/online.html" target="_top"><span class="strong"><strong>UNIX</strong></span></a> socket special file.
</dd><dt><span class="term"><code class="code">(RAWSOCK:IPCSUM <em class="replaceable"><code>buffer</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code>
- <a href="http://rfc.net//rfc791.html" target="_top"><span><strong class="command">IP</strong></span></a><br /></span><span class="term"><code class="code">(RAWSOCK:ICMPCSUM <em class="replaceable"><code>buffer</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code>
- <a href="http://rfc.net//rfc792.html" target="_top"><span><strong class="command">ICMP</strong></span></a><br /></span><span class="term"><code class="code">(RAWSOCK:TCPCSUM <em class="replaceable"><code>buffer</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code>
- <a href="http://rfc.net//rfc793.html" target="_top"><span><strong class="command">TCP</strong></span></a><br /></span><span class="term"><code class="code">(RAWSOCK:UDPCSUM <em class="replaceable"><code>buffer</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code>
- <a href="http://rfc.net//rfc768.html" target="_top"><span><strong class="command">UDP</strong></span></a></span></dt><dd>Compute the appropriate protocol checksum and record
it in the appropriate location. <em class="replaceable"><code>buffer</code></em> is assumed to be a suitable
packet for the protocol, with the appropriate header etc.
The typical packet you send is both <a href="http://rfc.net//rfc791.html" target="_top"><span><strong class="command">IP</strong></span></a> and <a href="http://rfc.net//rfc793.html" target="_top"><span><strong class="command">TCP</strong></span></a> and thus has two
checksums, so you would want to call <span class="emphasis"><em>two</em></span> functions.
</dd><dt><span class="term"><code class="code">(RAWSOCK:CONFIGDEV <em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>name</code></em> <em class="replaceable"><code>address</code></em>
<a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> <em class="replaceable"><code>promisc</code></em>
<em class="replaceable"><code>noarp</code></em>)</code></span></dt><dd>Set some socket options and IP <em class="replaceable"><code>address</code></em>
with <a class="unix" href="http://www.opengroup.org/onlinepubs/007904975/functions/ioctl.html"><code class="function">ioctl</code></a>.
</dd></dl></div></div></div><div class="bookinfo"><hr width="100%" /><table width="100%" summary="impnotes meta info"><th><td align="left">These notes document <a href="http://clisp.cons.org" target="_top"><span><strong class="command">CLISP</strong></span></a> version 2.36</td><td align="right">Last modified: 2005-12-04</td></th></table></div><div class="custom-footer"><hr width="100%" /><table width="100%"><tr><td align="left"><a href="http://clisp.cons.org"><img src="clisp.png" width="48" height="48" alt="[CLISP home]" /></a></td><td align="center"><a href="http://sourceforge.net/donate/index.php?group_id=1355"><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="[Support This Project]" /></a></td><td align="right"><a href="http://sourceforge.net"><img width="125" height="37" alt="[SourceForge]" src="http://sflogo.sourceforge.net/sflogo.php?group_id=1355&amp;type=2&amp;page=rawsock" /></a></td></tr></table></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="fastcgi.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ext-modules.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="wildcard.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">32.13. The FastCGI Interface </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 32.15. The Wildcard Module</td></tr></table></div></body></html>