[389e37]: impnotes / rawsock.html Maximize Restore History

Download this file

rawsock.html    195 lines (194 with data), 56.3 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?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>33.17. Raw Socket Access</title><link rel="stylesheet" type="text/css" href="impnotes.css" /><link rev="made" href="mailto:clisp-list@lists.sourceforge.net" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot_8706" /><link rel="home" href="index.html" title="Implementation Notes for GNU CLISP" /><link rel="up" href="ext-modules.html" title="Chapter 33. Extensions Implemented as Modules" /><link rel="prev" href="zlib.html" title="33.16. Interface to zlib" /><link rel="next" href="fastcgi.html" title="33.18. The FastCGI Interface" /><link rel="copyright" href="legalese.html" title="Legal Status of the CLISP Implementation Notes" /><meta name="date" content="'generated: 2010-07-07 11:48:49-04:00'" /><link rel="author" title="Authors" href="index.html#authors" /><link rel="contents" title="Table of Contents" href="index.html" /><link rel="glossary" href="glossary.html" /><link rel="help" href="faq.html#faq-help" title="How do I ask for help?" /><link rel="home" title="Home" href="http://clisp.cons.org" /><link rel="index" href="idx.html" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">33.17. Raw Socket Access</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="zlib.html">Prev</a> </td><th width="60%" align="center">Chapter 33. Extensions Implemented as Modules</th><td width="20%" align="right"> <a accesskey="n" href="fastcgi.html">Next</a></td></tr></table><hr /></div><div class="section" title="33.17. Raw Socket Access"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="rawsock"></a>33.17. Raw Socket Access</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="rawsock.html#rawsock-intro">33.17.1. Introduction</a></span></dt><dt><span class="section"><a href="rawsock.html#rawsock-func">33.17.2. Single System Call Functions</a></span></dt><dt><span class="section"><a href="rawsock.html#rawsock-args">33.17.3. Common arguments</a></span></dt><dd><dl><dt><span class="section"><a href="rawsock.html#rawsock-plat-dep-constants">33.17.3.1. Platform-dependent Keywords</a></span></dt></dl></dd><dt><span class="section"><a href="rawsock.html#rawsock-return">33.17.4. Return Values</a></span></dt><dt><span class="section"><a href="rawsock.html#rawsock-not-implemented">33.17.5. Not Implemented</a></span></dt><dt><span class="section"><a href="rawsock.html#rawsock-errors">33.17.6. Errors</a></span></dt><dt><span class="section"><a href="rawsock.html#rawsock-high-level">33.17.7. High-Level Functions</a></span></dt></dl></div><div class="section" title="33.17.1. Introduction"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-intro"></a>33.17.1. Introduction</h3></div></div></div><p>This is the raw socket interface, as described in
<a class="unix" href="http://www.opengroup.org/susv3/basedefs/sys/socket.h.html">&lt;<code class="filename">sys/socket.h</code>&gt;</a>.
Sockets are represented by their <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/typ_fixnum.html" target="_top"><code class="classname">FIXNUM</code></a> <a class="unix" href="http://www.opengroup.org/susv3/basedefs/xbd_chap03.html#tag_03_165">file descriptor</a>s.</p><p>When this module is present, <a href="features.html" class="olink"><code class="varname">*FEATURES*</code></a> contains the
symbol <code class="constant">:RAWSOCK</code>.</p><div class="warning" title="Try SOCKET:SOCKET-STREAM first!" 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 class="xref" href="socket.html" title="32.4. Socket Streams">Section 32.4, “Socket Streams”</a> are adequate and much more convenient than these.
You are encouraged to consider <a class="link" href="socket.html" title="32.4. 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" title="Do not use EXT:MAKE-STREAM!" 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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_stream.html" target="_top"><code class="classname">STREAM</code></a>
using <a class="link" href="make-stream.html" title="21.9. 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 <a class="" href="https://lists.sourceforge.net/lists/listinfo/clisp-devel">clisp-devel</a>
<a class="ulink" href="http://sourceforge.net/mailarchive/message.php?msg_id=7203955" target="_top">mailing list archives</a> for more details.
Note that <a class="link" href="make-stream.html" title="21.9. Function EXT:MAKE-STREAM"><code class="function">EXT:MAKE-STREAM</code></a> will duplicate the <a class="unix" href="http://www.opengroup.org/susv3/basedefs/xbd_chap03.html#tag_03_165">file descriptor</a> (using <a class="unix" href="http://www.opengroup.org/susv3/functions/dup.html"><code class="function">dup</code></a>),
so you <span class="emphasis"><em>still</em></span> have to <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_close.html" target="_top"><code class="function">CLOSE</code></a> the original raw socket.
</p></div><p>Test file <a class="clisp-cvs" href="http://clisp.cvs.sourceforge.net/*checkout*/clisp/clisp/modules/rawsock/test.tst"><code class="filename">modules/rawsock/test.tst</code></a>
and the demos in <a class="clisp-cvs" href="http://clisp.cvs.sourceforge.net/clisp/clisp/modules/rawsock/demos/"><code class="filename">modules/rawsock/demos/</code></a>
contain plenty of examples.</p></div><div class="section" title="33.17.2. Single System Call Functions"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-func"></a>33.17.2. Single System Call Functions</h3></div></div></div><p>We implement access to
</p><table border="0" summary="Simple list" class="simplelist"><tr><td><code class="code">(<a class="unix" href="http://www.opengroup.org/susv3/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/susv3/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/susv3/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/susv3/functions/getaddrinfo.html"><code class="function">getaddrinfo</code></a> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/getnameinfo.html"><code class="function">getnameinfo</code></a> <em class="replaceable"><code>address</code></em>
<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/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/susv3/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/susv3/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/susv3/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/susv3/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/susv3/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/susv3/functions/recv.html"><code class="function">recv</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>buffer</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/recvmsg.html"><code class="function">recvmsg</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>message</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/send.html"><code class="function">send</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>buffer</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/sendmsg.html"><code class="function">sendmsg</code></a>
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>message</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/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/susv3/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/susv3/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"><span class="quote">RAWSOCK</span></span></strong>.
Additionally,</p><table border="0" summary="Simple list" class="simplelist"><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/susv3/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/listen.html"><code class="function">listen</code></a>.</td></tr></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>When the OS does not provide <a class="unix" href="http://www.opengroup.org/susv3/functions/socketpair.html"><code class="function">socketpair</code></a>, it is emulated
using <a class="unix" href="http://www.opengroup.org/susv3/functions/socket.html"><code class="function">socket</code></a> + <a class="unix" href="http://www.opengroup.org/susv3/functions/connect.html"><code class="function">connect</code></a> +
<a class="unix" href="http://www.opengroup.org/susv3/functions/accept.html"><code class="function">accept</code></a>.</p></div></div><div class="section" title="33.17.3. Common arguments"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-args"></a>33.17.3. Common arguments</h3></div></div></div><div class="toc"><dl><dt><span class="section"><a href="rawsock.html#rawsock-plat-dep-constants">33.17.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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a> (returned by <a class="unix" href="http://www.opengroup.org/susv3/functions/socketpair.html"><code class="function">socketpair</code></a> or
<a class="unix" href="http://www.opengroup.org/susv3/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> (stands for <code class="constant">AF_UNSPEC</code>),
<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> (stands for 0); <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> (stands for 0); <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a> (passed
to <a class="unix" href="http://www.opengroup.org/susv3/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 class="ulink" href="http://c-faq.com/" target="_top"><span class="command"><strong>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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/cla_structure-object.html" target="_top"><code class="classname">STRUCTURE-OBJECT</code></a> <span class="type">RAWSOCK:SOCKADDR</span>
returned by
<a class="link" 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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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><p><span class="term">addr</span></p></td><td>
a <a class="link" href="rawsock.html#make-sockaddr"><span class="type">SOCKADDR</span></a>.
</td></tr><tr><td><p><span class="term">iovec</span></p></td><td>
a <span class="type"><code class="literal">(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> <span class="type"><code class="literal">(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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><p><span class="term">control</span></p></td><td>
a <span class="type"><code class="literal">(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><code class="classname">UNSIGNED-BYTE</code></a> 8))</code></span></td></tr><tr><td><p><span class="term">flags</span></p></td><td>
a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_list.html" target="_top"><code class="classname">LIST</code></a></td></tr></tbody></table></div></dd></dl></div><div class="section" title="33.17.3.1. Platform-dependent Keywords"><div class="titlepage"><div><div><h4 class="title"><a id="rawsock-plat-dep-constants"></a>33.17.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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/speope_block.html" target="_top"><code class="function">BLOCK</code></a> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>
(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_handler-bind.html" target="_top"><code class="function">HANDLER-BIND</code></a> ((<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/contyp_type-error.html" target="_top"><code class="classname">TYPE-ERROR</code></a>
(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_lambda.html" target="_top"><code class="function">LAMBDA</code></a> (c)
(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_format.html" target="_top"><code class="function">FORMAT</code></a> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a> "~&amp;error: ~A~%" c)
(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_return.html" target="_top"><code class="function">RETURN</code></a> (<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/acc_carcm_cdr_darcm_cddddr.html" target="_top"><code class="function">CDDR</code></a> (<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/acc_firstcm_s_inthcm_tenth.html" target="_top"><code class="function">THIRD</code></a> (<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_type-erro_xpected-type.html" target="_top"><code class="function">TYPE-ERROR-EXPECTED-TYPE</code></a> c)))))))
(rawsock:socket "bad" <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>)))
</pre></div></div><div class="section" title="33.17.4. Return Values"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-return"></a>33.17.4. Return Values</h3></div></div></div><p>The return values of the functions described in section
<a class="xref" href="rawsock.html#rawsock-func" title="33.17.2. Single System Call Functions">Section 33.17.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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/contyp_error.html" target="_top"><code class="classname">ERROR</code></a> is <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_signal.html" target="_top"><code class="function">SIGNAL</code></a>ed.</p></div><div class="section" title="33.17.5. Not Implemented"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-not-implemented"></a>33.17.5. Not Implemented</h3></div></div></div><p>We do not interface to <a class="unix" href="http://www.opengroup.org/susv3/functions/select.html"><code class="function">select</code></a>
or <a class="unix" href="http://www.opengroup.org/susv3/functions/poll.html"><code class="function">poll</code></a> in this module,
they are already available through <a class="link" 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/susv3/functions/shutdown.html"><code class="function">shutdown</code></a>
in this module, it is already available through <a class="link" 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/susv3/functions/gethostbyname.html"><code class="function">gethostbyname</code></a>
or <a class="unix" href="http://www.opengroup.org/susv3/functions/gethostbyaddr.html"><code class="function">gethostbyaddr</code></a> in this module,
they are already available through <a class="link" href="syscalls.html#resolve-host"><code class="function">POSIX:RESOLVE-HOST-IPADDR</code></a>.</p></div><div class="section" title="33.17.6. Errors"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-errors"></a>33.17.6. Errors</h3></div></div></div><p>Errors in <a class="unix" href="http://www.opengroup.org/susv3/functions/getaddrinfo.html"><code class="function">getaddrinfo</code></a>
and <a class="unix" href="http://www.opengroup.org/susv3/functions/getnameinfo.html"><code class="function">getnameinfo</code></a> are <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_signal.html" target="_top"><code class="function">SIGNAL</code></a>ed
as <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/contyp_condition.html" target="_top"><code class="classname">CONDITION</code></a>s of type <span class="type">RAWSOCK:EAI</span>
using <a class="unix" href="http://www.opengroup.org/susv3/functions/gai_strerror.html"><code class="function">gai_strerror</code></a>.</p><p>Errors in other functions are reported as the usual OS errors
(using <a class="unix" href="http://www.opengroup.org/susv3/functions/strerror.html"><code class="function">strerror</code></a>).</p></div><div class="section" title="33.17.7. High-Level Functions"><div class="titlepage"><div><div><h3 class="title"><a id="rawsock-high-level"></a>33.17.7. High-Level Functions</h3></div></div></div><div class="variablelist" title="Functions that do not correspond to a single system call"><a id="rawsock-high-level-list"></a><p class="title">Functions that do not
correspond to a single system call</p><dl><dt><a id="sock-read"></a><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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code></span></dt><dd><p class="simpara">Call one of <a class="unix" href="http://www.opengroup.org/susv3/functions/read.html"><code class="function">read</code></a>/<a class="unix" href="http://www.opengroup.org/susv3/functions/readv.html"><code class="function">readv</code></a>
or <a class="unix" href="http://www.opengroup.org/susv3/functions/write.html"><code class="function">write</code></a>/<a class="unix" href="http://www.opengroup.org/susv3/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> <span class="type"><code class="literal">(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_vector.html" target="_top"><code class="classname">VECTOR</code></a> (<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="simpara">When <a class="unix" href="http://www.opengroup.org/susv3/functions/readv.html"><code class="function">readv</code></a> and
<a class="unix" href="http://www.opengroup.org/susv3/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/susv3/functions/read.html"><code class="function">read</code></a> and <a class="unix" href="http://www.opengroup.org/susv3/functions/write.html"><code class="function">write</code></a>.</p><p class="simpara">On <a class="ulink" href="http://winehq.org/" target="_top"><span class="platform">Win32</span></a> we have to use <a class="unix" href="http://www.opengroup.org/susv3/functions/recv.html"><code class="function">recv</code></a>
instead of <a class="unix" href="http://www.opengroup.org/susv3/functions/read.html"><code class="function">read</code></a> and <a class="unix" href="http://www.opengroup.org/susv3/functions/send.html"><code class="function">send</code></a> instead of
<a class="unix" href="http://www.opengroup.org/susv3/functions/write.html"><code class="function">write</code></a> because <a class="ulink" href="http://winehq.org/" target="_top"><span class="platform">Win32</span></a> <a class="unix" href="http://www.opengroup.org/susv3/functions/read.html"><code class="function">read</code></a> and <a class="unix" href="http://www.opengroup.org/susv3/functions/write.html"><code class="function">write</code></a> do not work on sockets,
only on regular files.</p></dd><dt><a id="rawsock-protocol"></a><span class="term"><code class="code">(RAWSOCK:PROTOCOL
<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/getprotobyname.html"><code class="function">getprotobyname</code></a>
when <em class="replaceable"><code>protocol</code></em> is a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a>,
or call <a class="unix" href="http://www.opengroup.org/susv3/functions/getprotobynumber.html"><code class="function">getprotobynumber</code></a> when
<em class="replaceable"><code>protocol</code></em> is an <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>, return a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/setprotoent.html"><code class="function">setprotoent</code></a>,
<a class="unix" href="http://www.opengroup.org/susv3/functions/getprotoent.html"><code class="function">getprotoent</code></a>, and
<a class="unix" href="http://www.opengroup.org/susv3/functions/endprotoent.html"><code class="function">endprotoent</code></a>.
</dd><dt><a id="rawsock-network"></a><span class="term"><code class="code">(RAWSOCK:NETWORK
<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/getnetbyname.html"><code class="function">getnetbyname</code></a>
when <em class="replaceable"><code>network</code></em> is a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a>,
or call <a class="unix" href="http://www.opengroup.org/susv3/functions/getnetbyaddr.html"><code class="function">getnetbyaddr</code></a> when
<em class="replaceable"><code>network</code></em> is an <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>, return a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/setnetent.html"><code class="function">setnetent</code></a>,
<a class="unix" href="http://www.opengroup.org/susv3/functions/getnetent.html"><code class="function">getnetent</code></a>, and
<a class="unix" href="http://www.opengroup.org/susv3/functions/endnetent.html"><code class="function">endnetent</code></a>.
</dd><dt><a id="rawsock-if-name-index"></a><span class="term"><code class="code">(RAWSOCK:IF-NAME-INDEX
<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a> <em class="replaceable"><code>what</code></em>)</code></span></dt><dd>Call <a class="unix" href="http://www.opengroup.org/susv3/functions/if_nametoindex.html"><code class="function">if_nametoindex</code></a>
when <em class="replaceable"><code>what</code></em> is a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a> and return an <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a>;
or call <a class="unix" href="http://www.opengroup.org/susv3/functions/if_indextoname.html"><code class="function">if_indextoname</code></a> when
<em class="replaceable"><code>what</code></em> is an <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a> and return a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a>.
When <em class="replaceable"><code>what</code></em> is <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>, return an <a class="" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/glo_a.html#association_list">association list</a> of
pairs <span class="data"><code class="literal">(<em class="replaceable"><code>index</code></em> . <em class="replaceable"><code>name</code></em>)</code></span>
using <a class="unix" href="http://www.opengroup.org/susv3/functions/if_nameindex.html"><code class="function">if_nameindex</code></a>.
</dd><dt><a id="rawsock-ifaddrs"></a><span class="term"><code class="code">(RAWSOCK:IFADDRS
<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> :FLAGS-OR :FLAGS-AND)</code></span></dt><dd>Call <a class="bsd" href="http://www.freebsd.org/cgi/man.cgi?query=getifaddrs"><code class="function">getifaddrs</code></a>
and return a <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_list.html" target="_top"><code class="classname">LIST</code></a> of <span class="type">ifaddrs</span> objects, optionally
filtered using flags, e.g., <code class="code">(ifaddrs :flags-or '(a b)
:flags-and '(c d))</code> will return a list of objects which have
flags <code class="literal">c</code> <span class="strong"><strong>and</strong></span> <code class="literal">d</code> <span class="strong"><strong>and</strong></span> at
least one of <code class="literal">a</code> <span class="strong"><strong>or</strong></span> <code class="literal">b</code> set.
</dd><dt><a id="rawsock-sockopt"></a><span class="term"><code class="code">(RAWSOCK:SOCKET-OPTION
<em class="replaceable"><code>socket</code></em> <em class="replaceable"><code>name</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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/susv3/functions/getsockopt.html"><code class="function">getsockopt</code></a>
and <a class="unix" href="http://www.opengroup.org/susv3/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="link" href="socket.html#so-opt"><code class="function">SOCKET:SOCKET-OPTIONS</code></a>.)</dd><dt><a id="rawsock-convert-address"></a><span class="term"><code class="code">(<a class="link" href="rawsock.html#rawsock-convert-address"><code class="function">RAWSOCK:CONVERT-ADDRESS</code></a>
<em class="replaceable"><code>family</code></em> <em class="replaceable"><code>address</code></em>)</code></span></dt><dd><p>Convert between <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_string.html" target="_top"><code class="classname">STRING</code></a> and <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a> <a class="rfc" href="http://www.ietf.org/rfc/rfc791.txt"><code><span class="command"><strong>IP</strong></span></code></a>
<em class="replaceable"><code>address</code></em> representations using</p><table border="0" summary="Simple list" class="simplelist"><tr><td><a class="unix" href="http://www.opengroup.org/susv3/functions/inet_addr.html"><code class="function">inet_addr</code></a></td><td><a class="unix" href="http://www.opengroup.org/susv3/functions/inet_ntop.html"><code class="function">inet_ntop</code></a></td></tr><tr><td><a class="unix" href="http://www.opengroup.org/susv3/functions/inet_ntoa.html"><code class="function">inet_ntoa</code></a></td><td><a class="unix" href="http://www.opengroup.org/susv3/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/typ_unsigned-byte.html" target="_top"><code class="classname">UNSIGNED-BYTE</code></a> 8)</code></span> or an <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/syscla_integer.html" target="_top"><code class="classname">INTEGER</code></a>
(meaning <code class="code">(<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 symbolic <em class="replaceable"><code>family</code></em> 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 class="simpara">Return a <a class="" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/glo_f.html#fresh">fresh</a> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 class="ulink" href="http://c-faq.com/" target="_top"><span class="command"><strong>C</strong></span></a> <span class="type">struct sockaddr</span> object.</p><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>Modifying this <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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><a id="rawsock-unix-socket"></a><span class="term"><code class="code">(RAWSOCK:OPEN-UNIX-SOCKET
<em class="replaceable"><code>pathname</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a> (<em class="replaceable"><code>type</code></em> <code class="constant">:STREAM</code>))</code></span></dt><dd>Open a <a class="ulink" href="http://www.unix.org/online.html" target="_top"><span class="strong"><strong>UNIX</strong></span></a> socket special file.
Returns two values: <em class="replaceable"><code>socket</code></em> and <em class="replaceable"><code>address</code></em>.
</dd><dt><span class="term"><code class="code">(RAWSOCK:OPEN-UNIX-SOCKET-STREAM <em class="replaceable"><code>pathname</code></em>
<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;REST</code></a> <em class="replaceable"><code>options</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> (<em class="replaceable"><code>type</code></em> <code class="constant">:STREAM</code>)
<a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;ALLOW-OTHER-KEYS</code></a>)</code></span></dt><dd>Open a <a class="ulink" href="http://www.unix.org/online.html" target="_top"><span class="strong"><strong>UNIX</strong></span></a> socket special file.
Returns two values: <em class="replaceable"><code>stream</code></em> and <em class="replaceable"><code>address</code></em>. <em class="replaceable"><code>type</code></em> is passed
to <code class="function">RAWSOCK:OPEN-UNIX-SOCKET</code>, other <em class="replaceable"><code>options</code></em>
to <a class="link" href="make-stream.html" title="21.9. Function EXT:MAKE-STREAM"><code class="function">EXT:MAKE-STREAM</code></a> (but see <a class="xref" href="rawsock.html#rawsock-not-streams" title="Do not use EXT:MAKE-STREAM!">Do <span class="strong"><strong>not</strong></span> use <code class="function">EXT:MAKE-STREAM</code>!</a>).
</dd><dt><span class="term"><code class="code">(RAWSOCK:IPCSUM <em class="replaceable"><code>buffer</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code>
- <a class="rfc" href="http://www.ietf.org/rfc/rfc791.txt"><code><span class="command"><strong>IP</strong></span></code></a><br /></span><span class="term"><code class="code">(RAWSOCK:ICMPCSUM <em class="replaceable"><code>buffer</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code>
- <a class="rfc" href="http://www.ietf.org/rfc/rfc792.txt"><code><span class="command"><strong>ICMP</strong></span></code></a><br /></span><span class="term"><code class="code">(RAWSOCK:TCPCSUM <em class="replaceable"><code>buffer</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code>
- <a class="rfc" href="http://www.ietf.org/rfc/rfc793.txt"><code><span class="command"><strong>TCP</strong></span></code></a><br /></span><span class="term"><code class="code">(RAWSOCK:UDPCSUM <em class="replaceable"><code>buffer</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> start end)</code>
- <a class="rfc" href="http://www.ietf.org/rfc/rfc768.txt"><code><span class="command"><strong>UDP</strong></span></code></a></span></dt><dd><p class="simpara">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
ethernet frame for the protocol, with the appropriate header etc.</p><p class="simpara">Note that <em class="replaceable"><code>buffer</code></em> is an <span class="emphasis"><em>ethernet frame</em></span>,
starting with 6 bytes of the destination MAC address, 6 bytes of the
source MAC address, and 2 bytes specifying the next level protocol,
(e.g., <code class="literal">#x0800</code> for <a class="rfc" href="http://www.ietf.org/rfc/rfc791.txt"><code><span class="command"><strong>IP</strong></span></code></a> and <code class="literal">#x0806</code>
for <a class="rfc" href="http://www.ietf.org/rfc/rfc826.txt"><code><span class="command"><strong>ARP</strong></span></code></a>), i.e., the first 14 bytes of <em class="replaceable"><code>buffer</code></em> are ignored by these
functions.</p><p class="simpara">A typical packet you send is both <a class="rfc" href="http://www.ietf.org/rfc/rfc791.txt"><code><span class="command"><strong>IP</strong></span></code></a> and <a class="rfc" href="http://www.ietf.org/rfc/rfc793.txt"><code><span class="command"><strong>TCP</strong></span></code></a> and thus
has two checksums, so you would want to call <span class="emphasis"><em>two</em></span>
functions.</p></dd><dt><span class="term"><code class="code">(RAWSOCK:CONFIGDEV <em class="replaceable"><code>socket</code></em>
<em class="replaceable"><code>ifname</code></em> <em class="replaceable"><code>address</code></em> <a class="ulink" href="http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/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 <a class="rfc" href="http://www.ietf.org/rfc/rfc791.txt"><code><span class="command"><strong>IP</strong></span></code></a> <em class="replaceable"><code>address</code></em>
with <a class="unix" href="http://www.opengroup.org/susv3/functions/ioctl.html"><code class="function">ioctl</code></a>.
</dd></dl></div></div></div><div class="bookinfo"><hr /><table width="100%" summary="impnotes meta info"><th><td align="left">These notes document <a class="ulink" href="http://clisp.cons.org" target="_top"><span class="command"><strong>CLISP</strong></span></a> version 2.49</td><td align="right">Last modified: 2010-07-07</td></th></table></div><div class="custom-footer"><hr /><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="https://sourceforge.net/donate/index.php?group_id=1355"><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" alt="[Support CLISP]" /></a></td><td align="right"><a href="https://sourceforge.net/projects/clisp"><img width="120" height="30" alt="[SourceForge]" src="http://sflogo.sourceforge.net/sflogo.php?group_id=1355&amp;type=12&amp;page=rawsock" /></a></td></tr></table></div><hr /><form method="get" action="http://www.google.com/custom" target="_top"><table width="100%" border="0"><tr><td nowrap="nowrap" align="center"><input type="hidden" name="domains" value="clisp.cons.org;clisp.podval.org;www.lisp.org" /><label for="sbi" style="display: none">Enter your search terms</label><input type="text" name="q" size="50" maxlength="255" id="sbi" value="33.17. Raw Socket Access" /><label for="sbb" style="display: none">Submit search form</label><input type="submit" name="sa" value="Google Search" id="sbb" /></td></tr><tr><td nowrap="nowrap" align="center"><input type="radio" name="sitesearch" value="" checked="1" id="ss0" /><label for="ss0" title="Search the Web"><small>Web</small></label><input type="radio" name="sitesearch" value="clisp.cons.org" id="ss1" /><label for="ss1" title="Search clisp.cons.org"><small>clisp.cons.org</small></label><input type="radio" name="sitesearch" value="clisp.podval.org" id="ss2" /><label for="ss2" title="Search clisp.podval.org"><small>clisp.podval.org</small></label><input type="radio" name="sitesearch" value="www.lisp.org" id="ss3" /><label for="ss3" title="Search www.lisp.org"><small>www.lisp.org</small></label><input type="hidden" name="client" value="pub-4445255502750357" /><input type="hidden" name="forid" value="1" /><input type="hidden" name="ie" value="UTF-8" /><input type="hidden" name="oe" value="UTF-8" /><input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:000000;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:48;LW:48;L:http://clisp.cons.org/clisp.png;S:http://clisp.cons.org;FORID:1" /><input type="hidden" name="hl" value="en" /></td></tr></table></form><hr /><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="zlib.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="fastcgi.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">33.16. Interface to zlib </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 33.18. The FastCGI Interface</td></tr></table></div></body></html>