This file is indexed.

/usr/share/doc/racket/reference/tcp.html is in racket-doc 6.1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>15.3.1&nbsp;TCP</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="extras.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x"><span style="font-weight: bold">The Racket Reference</span></a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="input-and-output.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14&nbsp;</td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15&nbsp;</td><td><a href="os.html" class="tocviewselflink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16&nbsp;</td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17&nbsp;</td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operations</a></td></tr><tr><td align="right">18&nbsp;</td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">Running Racket</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9658;</a></td><td>15&nbsp;</td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr></table><div class="tocviewsublist" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">15.1&nbsp;</td><td><a href="pathutils.html" class="tocviewlink" data-pltdoc="x">Paths</a></td></tr><tr><td align="right">15.2&nbsp;</td><td><a href="Filesystem.html" class="tocviewlink" data-pltdoc="x">Filesystem</a></td></tr><tr><td align="right">15.3&nbsp;</td><td><a href="networking.html" class="tocviewselflink" data-pltdoc="x">Networking</a></td></tr><tr><td align="right">15.4&nbsp;</td><td><a href="subprocess.html" class="tocviewlink" data-pltdoc="x">Processes</a></td></tr><tr><td align="right">15.5&nbsp;</td><td><a href="logging.html" class="tocviewlink" data-pltdoc="x">Logging</a></td></tr><tr><td align="right">15.6&nbsp;</td><td><a href="time.html" class="tocviewlink" data-pltdoc="x">Time</a></td></tr><tr><td align="right">15.7&nbsp;</td><td><a href="envvars.html" class="tocviewlink" data-pltdoc="x">Environment Variables</a></td></tr><tr><td align="right">15.8&nbsp;</td><td><a href="runtime.html" class="tocviewlink" data-pltdoc="x">Environment and Runtime Information</a></td></tr><tr><td align="right">15.9&nbsp;</td><td><a href="Command-Line_Parsing.html" class="tocviewlink" data-pltdoc="x">Command-<wbr></wbr>Line Parsing</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_2&quot;);">&#9660;</a></td><td>15.3&nbsp;</td><td><a href="networking.html" class="tocviewlink" data-pltdoc="x">Networking</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_2"><table cellspacing="0" cellpadding="0"><tr><td align="right">15.3.1&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">TCP</a></td></tr><tr><td align="right">15.3.2&nbsp;</td><td><a href="udp.html" class="tocviewlink" data-pltdoc="x">UDP</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listen%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>listen</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>connect</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%2Fenable-break%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>connect/<span class="mywbr"> &nbsp;</span>enable-<wbr></wbr>break</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>accept</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%2Fenable-break%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>accept/<span class="mywbr"> &nbsp;</span>enable-<wbr></wbr>break</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept-ready~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>accept-<wbr></wbr>ready?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-close%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>close</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listener~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>listener?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept-evt%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>accept-<wbr></wbr>evt</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-abandon-port%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>abandon-<wbr></wbr>port</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-addresses%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>addresses</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-port~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>port?</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.1&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="networking.html" title="backward to &quot;15.3 Networking&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="networking.html" title="up to &quot;15.3 Networking&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="udp.html" title="forward to &quot;15.3.2 UDP&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div><h5 x-source-module="(lib &quot;scribblings/reference/reference.scrbl&quot;)" x-part-tag="&quot;tcp&quot;">15.3.1<tt>&nbsp;</tt><a name="(part._tcp)"></a><a name="(mod-path._racket/tcp)"></a>TCP</h5><p><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/tcp</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller">&nbsp;package:</span> <span class="stt">base</span></span></td></tr></table></div><div class="SIntrapara">The bindings documented in this section are provided by the <a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/tcp</span></a> and <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket</span></a> libraries, but not <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/base</span></a>.</div></p><p>For information about TCP in general, see <span style="font-style: italic">TCP/IP Illustrated,
Volume 1</span> by W. Richard Stevens.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-listen))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listen%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-listen</a></span></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">port-no</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span>[</td><td><span class="RktVar">max-allow-wait</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">reuse?</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">hostname</span>]<span class="RktPn">)</span></td><td><span class="hspace">&nbsp;</span></td><td>&rarr;</td><td><span class="hspace">&nbsp;</span></td><td><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listener~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-listener?</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">port-no</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._integer-in%29%29" class="RktValLink" data-pltdoc="x">integer-in</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">65535</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">max-allow-wait</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-nonnegative-integer~3f%29%29" class="RktValLink" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">4</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">reuse?</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">#f</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">hostname</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">#f</span></td></tr></table></blockquote></div><div class="SIntrapara">Creates a &ldquo;listening&rdquo; server on the local machine at the port number
specified by <span class="RktVar">port-no</span>. If <span class="RktVar">port-no</span> is 0 the socket binds
to an ephemeral port, which can be determined by calling
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-addresses%29%29" class="RktValLink" data-pltdoc="x">tcp-addresses</a></span>.  The <span class="RktVar">max-allow-wait</span> argument
determines the maximum number of client connections that can be
waiting for acceptance. (When <span class="RktVar">max-allow-wait</span> clients are
waiting acceptance, no new client connections can be made.)</div></p><p>If the <span class="RktVar">reuse?</span> argument is true, then <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listen%29%29" class="RktValLink" data-pltdoc="x">tcp-listen</a></span> will
create a listener even if the port is involved in a <span class="stt">TIME_WAIT</span>
state. Such a use of <span class="RktVar">reuse?</span> defeats certain guarantees of the
TCP protocol; see Stevens&rsquo;s book for details. Furthermore, on many
modern platforms, a true value for <span class="RktVar">reuse?</span> overrides
<span class="stt">TIME_WAIT</span> only if the listener was previously created with a true
value for <span class="RktVar">reuse?</span>.</p><p>If <span class="RktVar">hostname</span> is <span class="RktVal">#f</span> (the default), then the listener
accepts connections to all of the listening machine&rsquo;s addresses.
Otherwise, the listener accepts connections only at the interface(s)
associated with the given hostname. For example, providing
<span class="RktVal">"127.0.0.1"</span> as <span class="RktVar">hostname</span> creates a listener that
accepts only connections to <span class="RktVal">"127.0.0.1"</span> (the loopback
interface) from the local machine.</p><p>(Racket implements a listener with multiple sockets, if necessary, to
accommodate multiple addresses with different protocol families. On
Linux, if <span class="RktVar">hostname</span> maps to both IPv4 and IPv6 addresses, then
the behavior depends on whether IPv6 is supported and IPv6 sockets can
be configured to listen to only IPv6 connections: if IPv6 is not
supported or IPv6 sockets are not configurable, then the IPv6
addresses are ignored; otherwise, each IPv6 listener accepts only IPv6
connections.)</p><p>The return value of <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listen%29%29" class="RktValLink" data-pltdoc="x">tcp-listen</a></span> is a <a name="(tech._tcp._listener)"></a><span style="font-style: italic">TCP
listener</span>. This value can be used in future calls to
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span>, <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept-ready~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-accept-ready?</a></span>, and
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-close%29%29" class="RktValLink" data-pltdoc="x">tcp-close</a></span>.  Each new TCP listener value is placed into the
management of the current custodian (see <a href="custodians.html" data-pltdoc="x">Custodians</a>).</p><p>If the server cannot be started by <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listen%29%29" class="RktValLink" data-pltdoc="x">tcp-listen</a></span>, the
<span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3anetwork%29%29" class="RktValLink" data-pltdoc="x">exn:fail:network</a></span> exception is raised.</p><p>A TCP listener can be used as a <a href="sync.html#%28tech._synchronizable._event%29" class="techoutside" data-pltdoc="x"><span class="techinside">synchronizable event</span></a> (see <a href="sync.html" data-pltdoc="x">Events</a>).
A TCP listener is <a href="sync.html#%28tech._ready._for._synchronization%29" class="techoutside" data-pltdoc="x"><span class="techinside">ready for synchronization</span></a> when
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span> would not block; the <a href="sync.html#%28tech._synchronization._result%29" class="techoutside" data-pltdoc="x"><span class="techinside">synchronization result</span></a> of a TCP listener is the TCP listener itself.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-connect))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-connect</a></span></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">hostname</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">port-no</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span>[</td><td><span class="RktVar">local-hostname</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">local-port-no</span>]<span class="RktPn">)</span></td><td><span class="hspace">&nbsp;</span></td><td>&rarr;</td><td><span class="hspace">&nbsp;</span></td><td><table cellspacing="0" cellpadding="0"><tr><td><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._input-port~3f%29%29" class="RktValLink" data-pltdoc="x">input-port?</a></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._output-port~3f%29%29" class="RktValLink" data-pltdoc="x">output-port?</a></span></td></tr></table></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">hostname</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">port-no</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._integer-in%29%29" class="RktValLink" data-pltdoc="x">integer-in</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">65535</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">local-hostname</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">#f</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">local-port-no</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._integer-in%29%29" class="RktValLink" data-pltdoc="x">integer-in</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">65535</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">#f</span></td></tr></table></blockquote></div><div class="SIntrapara">Attempts to connect as a client to a listening server.  The
<span class="RktVar">hostname</span> argument is the server host&rsquo;s Internet address name,
and <span class="RktVar">port-no</span> is the port number where the server is listening.</div></p><p>(If <span class="RktVar">hostname</span> is associated with multiple addresses, they are
tried one at a time until a connection succeeds. The name
<span class="RktVal">"localhost"</span> generally specifies the local machine.)</p><p>The optional <span class="RktVar">local-hostname</span> and <span class="RktVar">local-port-no</span>
specify the client&rsquo;s address and port. If both are <span class="RktVal">#f</span> (the
default), the client&rsquo;s address and port are selected automatically. If
<span class="RktVar">local-hostname</span> is not <span class="RktVal">#f</span>, then
<span class="RktVar">local-port-no</span> must be non-<span class="RktVal">#f</span>. If
<span class="RktVar">local-port-no</span> is non-<span class="RktVal">#f</span> and <span class="RktVar">local-hostname</span>
is <span class="RktVal">#f</span>, then the given port is used but the address is
selected automatically.</p><p>Two values are returned by <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%29%29" class="RktValLink" data-pltdoc="x">tcp-connect</a></span>: an input port and an
output port. Data can be received from the server through the input
port and sent to the server through the output port.  If the server is
a Racket program, it can obtain ports to communicate to the
client with <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span>.  These ports are placed into the
management of the current custodian (see <a href="custodians.html" data-pltdoc="x">Custodians</a>).</p><p>Initially, the returned input port is block-buffered, and the returned
output port is block-buffered. Change the buffer mode using
<span class="RktSym"><a href="port-buffers.html#%28def._%28%28quote._~23~25kernel%29._file-stream-buffer-mode%29%29" class="RktValLink" data-pltdoc="x">file-stream-buffer-mode</a></span>.</p><p>Both of the returned ports must be closed to terminate the TCP
connection. When both ports are still open, closing the output port
with <span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._close-output-port%29%29" class="RktValLink" data-pltdoc="x">close-output-port</a></span> sends a TCP close to the server (which
is seen as an end-of-file if the server reads the connection through a
port). In contrast, <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-abandon-port%29%29" class="RktValLink" data-pltdoc="x">tcp-abandon-port</a></span> (see below) closes the
output port, but does not send a TCP close until the input port is
also closed.</p><p>Note that the TCP protocol does not support a state where one end is
willing to send but not read, nor does it include an automatic message
when one end of a connection is fully closed. Instead, the other end
of a connection discovers that one end is fully closed only as a
response to sending data; in particular, some number of writes on the
still-open end may appear to succeed, though writes will eventually
produce an error.</p><p>If a connection cannot be established by <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%29%29" class="RktValLink" data-pltdoc="x">tcp-connect</a></span>, the
<span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3anetwork%29%29" class="RktValLink" data-pltdoc="x">exn:fail:network</a></span> exception is raised.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-connect/enable-break))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%2Fenable-break%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-connect/enable-break</a></span></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">hostname</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">port-no</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span>[</td><td><span class="RktVar">local-hostname</span>]</td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">local-port-no</span><span class="RktPn">)</span></td><td><span class="hspace">&nbsp;</span></td></tr></table></blockquote></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="prototype"><tr><td><span class="hspace">&nbsp;</span></td><td>&rarr;</td><td><span class="hspace">&nbsp;</span></td><td><table cellspacing="0" cellpadding="0"><tr><td><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._input-port~3f%29%29" class="RktValLink" data-pltdoc="x">input-port?</a></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._output-port~3f%29%29" class="RktValLink" data-pltdoc="x">output-port?</a></span></td></tr></table></td></tr></table></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">hostname</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">port-no</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._integer-in%29%29" class="RktValLink" data-pltdoc="x">integer-in</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">65535</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">local-hostname</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">#f</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">local-port-no</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._integer-in%29%29" class="RktValLink" data-pltdoc="x">integer-in</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">65535</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%29%29" class="RktValLink" data-pltdoc="x">tcp-connect</a></span>, but breaking is enabled (see
<a href="breakhandler.html" data-pltdoc="x">Breaks</a>) while trying to connect. If breaking is
disabled when <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%2Fenable-break%29%29" class="RktValLink" data-pltdoc="x">tcp-connect/enable-break</a></span> is called, then either
ports are returned or the <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3abreak%29%29" class="RktValLink" data-pltdoc="x">exn:break</a></span> exception is raised, but
not both.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-accept))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-accept</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">listener</span><span class="RktPn">)</span></td><td><span class="hspace">&nbsp;</span></td><td>&rarr;</td><td><span class="hspace">&nbsp;</span></td><td><table cellspacing="0" cellpadding="0"><tr><td><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._input-port~3f%29%29" class="RktValLink" data-pltdoc="x">input-port?</a></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._output-port~3f%29%29" class="RktValLink" data-pltdoc="x">output-port?</a></span></td></tr></table></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">listener</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listener~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-listener?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Accepts a client connection for the server associated with
<span class="RktVar">listener</span>. If no client connection is waiting on the
listening port, the call to <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span> will block. (See also
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept-ready~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-accept-ready?</a></span>.)</div></p><p>Two values are returned by <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span>: an input port and an
output port. Data can be received from the client through the input
port and sent to the client through the output port.  These ports are
placed into the management of the current custodian (see
<a href="custodians.html" data-pltdoc="x">Custodians</a>).</p><p>In terms of buffering and connection states, the ports act the same as
ports from <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%29%29" class="RktValLink" data-pltdoc="x">tcp-connect</a></span>.</p><p>If a connection cannot be accepted by <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span>, or if the
listener has been closed, the <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3anetwork%29%29" class="RktValLink" data-pltdoc="x">exn:fail:network</a></span> exception is raised.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-accept/enable-break))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%2Fenable-break%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-accept/enable-break</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">listener</span><span class="RktPn">)</span></td><td><span class="hspace">&nbsp;</span></td><td>&rarr;</td><td><span class="hspace">&nbsp;</span></td><td><table cellspacing="0" cellpadding="0"><tr><td><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._input-port~3f%29%29" class="RktValLink" data-pltdoc="x">input-port?</a></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._output-port~3f%29%29" class="RktValLink" data-pltdoc="x">output-port?</a></span></td></tr></table></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">listener</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listener~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-listener?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span>, but breaking is enabled (see
<a href="breakhandler.html" data-pltdoc="x">Breaks</a>) while trying to accept a connection. If
breaking is disabled when <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%2Fenable-break%29%29" class="RktValLink" data-pltdoc="x">tcp-accept/enable-break</a></span> is called,
then either ports are returned or the <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3abreak%29%29" class="RktValLink" data-pltdoc="x">exn:break</a></span> exception is
raised, but not both.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-accept-ready~3f))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept-ready~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-accept-ready?</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">listener</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">listener</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listener~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-listener?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Tests whether an unaccepted client has connected to the server
associated with <span class="RktVar">listener</span>. If a client is
waiting, the return value is <span class="RktVal">#t</span>, otherwise it is
<span class="RktVal">#f</span>. A client is accepted with the <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span>
procedure, which returns ports for communicating with the client and
removes the client from the list of unaccepted clients.</div></p><p>If the listener has been closed, the <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3anetwork%29%29" class="RktValLink" data-pltdoc="x">exn:fail:network</a></span> exception is raised.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-close))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-close%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-close</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">listener</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">listener</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listener~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-listener?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Shuts down the server associated with <span class="RktVar">listener</span>. All
unaccepted clients receive an end-of-file from the server; connections
to accepted clients are unaffected.</div></p><p>If the listener has already been closed, the <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3anetwork%29%29" class="RktValLink" data-pltdoc="x">exn:fail:network</a></span> exception is raised.</p><p>The listener&rsquo;s port number may not become immediately available for
new listeners (with the default <span class="RktVar">reuse?</span> argument of
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listen%29%29" class="RktValLink" data-pltdoc="x">tcp-listen</a></span>). For further information, see Stevens&rsquo;s
explanation of the <span class="stt">TIME_WAIT</span> TCP state.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-listener~3f))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listener~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-listener?</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">v</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">v</span> is a <a href="#%28tech._tcp._listener%29" class="techoutside" data-pltdoc="x"><span class="techinside">TCP listener</span></a> created by
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listen%29%29" class="RktValLink" data-pltdoc="x">tcp-listen</a></span>, <span class="RktVal">#f</span> otherwise.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-accept-evt))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept-evt%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-accept-evt</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">listener</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="sync.html#%28def._%28%28quote._~23~25kernel%29._evt~3f%29%29" class="RktValLink" data-pltdoc="x">evt?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">listener</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listener~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-listener?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns a <a href="sync.html#%28tech._synchronizable._event%29" class="techoutside" data-pltdoc="x"><span class="techinside">synchronizable event</span></a> (see <a href="sync.html" data-pltdoc="x">Events</a>) that is
<a href="sync.html#%28tech._ready._for._synchronization%29" class="techoutside" data-pltdoc="x"><span class="techinside">ready for synchronization</span></a> when <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span> on <span class="RktVar">listener</span> would
not block. The <a href="sync.html#%28tech._synchronization._result%29" class="techoutside" data-pltdoc="x"><span class="techinside">synchronization result</span></a> is a
list of two items, which correspond to the two results of
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span>. (If the event is not chosen in a <span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._syntax%29%29" class="RktStxLink" data-pltdoc="x">syntax</a></span>, no connections are
accepted.) The ports are placed into the management of the custodian
that is the current custodian (see <a href="custodians.html" data-pltdoc="x">Custodians</a>) at the time that
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept-evt%29%29" class="RktValLink" data-pltdoc="x">tcp-accept-evt</a></span> is called.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-abandon-port))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-abandon-port%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-abandon-port</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">tcp-port</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">tcp-port</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-port~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-port?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._close-output-port%29%29" class="RktValLink" data-pltdoc="x">close-output-port</a></span> or <span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._close-input-port%29%29" class="RktValLink" data-pltdoc="x">close-input-port</a></span>
(depending on whether <span class="RktVar">tcp-port</span> is an input or output port),
but if <span class="RktVar">tcp-port</span> is an output port and its associated input
port is not yet closed, then the other end of the TCP connection does
not receive a TCP close message until the input port is also
closed.</div></p><p>The TCP protocol does not include a &ldquo;no longer reading&rdquo; state on
connections, so <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-abandon-port%29%29" class="RktValLink" data-pltdoc="x">tcp-abandon-port</a></span> is equivalent to
<span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._close-input-port%29%29" class="RktValLink" data-pltdoc="x">close-input-port</a></span> on input <a href="#%28tech._tcp._port%29" class="techoutside" data-pltdoc="x"><span class="techinside">TCP ports</span></a>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-addresses))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-addresses%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-addresses</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">tcp-port</span><span class="hspace">&nbsp;</span>[<span class="RktVar">port-numbers?</span>]<span class="RktPn">)</span></p></blockquote></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="prototype"><tr><td><span class="hspace">&nbsp;</span></td><td>&rarr;</td><td><span class="hspace">&nbsp;</span></td><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="values.html#%28def._%28%28quote._~23~25kernel%29._values%29%29" class="RktValLink" data-pltdoc="x">values</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="values.html#%28def._%28%28quote._~23~25kernel%29._values%29%29" class="RktValLink" data-pltdoc="x">values</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._integer-in%29%29" class="RktValLink" data-pltdoc="x">integer-in</a></span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">65535</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._integer-in%29%29" class="RktValLink" data-pltdoc="x">integer-in</a></span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">65535</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">tcp-port</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-port~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-port?</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-listener~3f%29%29" class="RktValLink" data-pltdoc="x">tcp-listener?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">port-numbers?</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">#f</span></td></tr></table></blockquote></div><div class="SIntrapara">Returns two strings when <span class="RktVar">port-numbers?</span> is <span class="RktVal">#f</span> (the
default). The first string is the Internet address for the local
machine a viewed by the given <a href="#%28tech._tcp._port%29" class="techoutside" data-pltdoc="x"><span class="techinside">TCP port</span></a>&rsquo;s connection or for the
TCP listener. (For most machines, the answer corresponds to the
current machine&rsquo;s only Internet address, but when a machine serves
multiple addresses, the result is connection-specific or
listener-specific.) If a listener is given and it has no specific
host, the first string result is <span class="RktVal">"0.0.0.0"</span>. The second string
is the Internet address for the other end of the connection, or always
<span class="RktVal">"0.0.0.0"</span> for a listener.</div></p><p>If <span class="RktVar">port-numbers?</span> is true, then four results are returned: a
string for the local machine&rsquo;s address, an exact integer between
<span class="RktVal">1</span> and <span class="RktVal">65535</span> for the local machine&rsquo;s port number, a
string for the remote machine&rsquo;s address, and an exact integer between
<span class="RktVal">1</span> and <span class="RktVal">65535</span> for the remote machine&rsquo;s port number or
<span class="RktVal">0</span> for a listener.</p><p>If the given port has been closed, the <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3anetwork%29%29" class="RktValLink" data-pltdoc="x">exn:fail:network</a></span> exception is raised.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/tcp..rkt)._tcp-port~3f))"></a><span title="Provided from: racket/tcp, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-port~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-port?</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">v</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">v</span> is a <a name="(tech._tcp._port)"></a><span style="font-style: italic">TCP port</span>&#8212;<wbr></wbr>which is a
port returned by <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%29%29" class="RktValLink" data-pltdoc="x">tcp-accept</a></span>, <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%29%29" class="RktValLink" data-pltdoc="x">tcp-connect</a></span>,
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-accept%2Fenable-break%29%29" class="RktValLink" data-pltdoc="x">tcp-accept/enable-break</a></span>, or
<span class="RktSym"><a href="#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%2Fenable-break%29%29" class="RktValLink" data-pltdoc="x">tcp-connect/enable-break</a></span>&#8212;<wbr></wbr><span class="RktVal">#f</span> otherwise.</div></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.1&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="networking.html" title="backward to &quot;15.3 Networking&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="networking.html" title="up to &quot;15.3 Networking&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="udp.html" title="forward to &quot;15.3.2 UDP&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>