world using <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._ground-vm%29%29"class="RktStxLink"data-pltdoc="x">ground-vm</a></span>-level event-based subscriptions.</div></p></div><divclass="SIntrapara">Returns a <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%29%29"class="RktStxLink"data-pltdoc="x">spawn</a></span> which starts an event-relay process with
debug-name <spanclass="RktVal">`</span><spanclass="RktVal">(</span><spanclass="RktVal">event-relay</span><spanclass="stt"></span><spanclass="RktRdr">,</span><spanclass="RktVar">self-id</span><spanclass="RktVal">)</span>.</div><divclass="SIntrapara">The relay process observes subscriptions matching the topic-pattern
<spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29"class="RktValLink"data-pltdoc="x">cons</a></span><spanclass="stt"></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="stt"></span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/sync.html#%28def._%28%28quote._~23~25kernel%29._evt~3f%29%29"class="RktValLink"data-pltdoc="x">evt?</a></span><spanclass="RktPn">)</span><spanclass="stt"></span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29"class="RktStxLink"data-pltdoc="x">_</a></span><spanclass="RktPn">)</span>, and when one appears, constructs an
analogous one using <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29"class="RktValLink"data-pltdoc="x">at-meta-level</a></span> to connect to the next VM
the subscription at the meta-level as well.</div></p><h4>4.2<tt> </tt><aname="(part._tcp-bare)"></a><aname="(mod-path._marketplace/drivers/tcp-bare)"></a>tcp-bare</h4><p><divclass="SIntrapara"><tablecellspacing="0"class="defmodule"><tr><tdalign="left"colspan="2"><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29"class="RktStxLink"data-pltdoc="x">require</a></span><spanclass="stt"></span><ahref="Drivers.html#%28mod-path._marketplace%2Fdrivers%2Ftcp-bare%29"class="RktModLink"data-pltdoc="x"><spanclass="RktSym">marketplace/drivers/tcp-bare</span></a><spanclass="RktPn">)</span></td></tr><tr><tdalign="left"> </td><tdalign="right"><spanclass="RpackageSpec"><spanclass="Smaller"> package:</span><spanclass="stt">marketplace</span></span></td></tr></table></div><divclass="SIntrapara">This module is only available for use by untyped Racket processes. It
is included by default in programs using <spanclass="stt">#lang marketplace</span>; see
<ahref="high-level-interface.html#%28part._hashlang-variations%29"data-pltdoc="x">Using <spanclass="stt">#lang marketplace</span> and friends</a> for information on other language
variants.</div><divclass="SIntrapara"><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-driver))"></a><spantitle="Provided from: marketplace/drivers/tcp-bare"><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-driver%29%29"class="RktValDef RktValLink"data-pltdoc="x">tcp-driver</a></span></span><spanclass="RktPn"></span><spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Spawn%29%29"class="RktValLink"data-pltdoc="x">Spawn</a></span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">Returns a <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%29%29"class="RktStxLink"data-pltdoc="x">spawn</a></span> action which starts a TCP driver. The TCP
(local-to-remote) bytestream.</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._.Tcp.Sub.Packet))"></a><spantitle="Provided from: marketplace/drivers/tcp-bare"><spanclass="RktSym"><spanclass="RktSymDef RktSym">TcpSubPacket</span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">or/c</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/port-ops.html#%28def._%28%28quote._~23~25kernel%29._eof-object~3f%29%29"class="RktValLink"data-pltdoc="x">eof-object?</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/bytestrings.html#%28def._%28%28quote._~23~25kernel%29._bytes~3f%29%29"class="RktValLink"data-pltdoc="x">bytes?</a></span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">Packets carried by <spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-channel%29%29"class="RktValLink"data-pltdoc="x">tcp-channel</a></span> structures are either
vectors.</div></p><h5>4.2.2<tt> </tt><aname="(part._.T.C.P_addresses)"></a>TCP addresses</h5><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._.Tcp.Address))"></a><spantitle="Provided from: marketplace/drivers/tcp-bare"><spanclass="RktSym"><spanclass="RktSymDef RktSym">TcpAddress</span></span></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">or/c</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-address~3f%29%29"class="RktValLink"data-pltdoc="x">tcp-address?</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-handle~3f%29%29"class="RktValLink"data-pltdoc="x">tcp-handle?</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-listener~3f%29%29"class="RktValLink"data-pltdoc="x">tcp-listener?</a></span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">A TCP address describes one end of a TCP connection. It can be either</div></p><ul><li><p>a <spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-address%29%29"class="RktValLink"data-pltdoc="x">tcp-address</a></span>, representing a remote socket;</p></li><li><p>a <spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-handle%29%29"class="RktValLink"data-pltdoc="x">tcp-handle</a></span>, representing a local socket on a kernel-assigned port; or</p></li><li><p>a <spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-listener%29%29"class="RktValLink"data-pltdoc="x">tcp-listener</a></span>, representing a local socket on a user-assigned port.</p></li></ul><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-address-port))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-address-host))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-address~3f))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._struct~3atcp-address))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-address))"></a><spantitle="Provided from: marketplace/drivers/tcp-bare"><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-address%29%29"class="RktValDef RktValLink"data-pltdoc="x">tcp-address</a></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">host</span><spanclass="stt"></span><spanclass="RktSym">port</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">host</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahre
ASCII representation of an IP address (e.g. <spanclass="RktVal">"127.0.0.1"</span>).</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-handle-id))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-handle~3f))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._struct~3atcp-handle))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-handle))"></a><spantitle="Provided from: marketplace/drivers/tcp-bare"><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-handle%29%29"class="RktValDef RktValLink"data-pltdoc="x">tcp-handle</a></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">id</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">id</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym">any/c</span></td></tr></table></blockquote></div><divclass="SIntrapara">Describes a local half-connection with a kernel-assigned port number.
The port number is not directly accessible; the <spanclass="RktSym">id</span> is used as
a local name for whichever underlying port number ends up being used.</div></p><p>The <spanclass="RktSym">id</span> must be chosen carefully: it is scoped to the local
VM, i.e. shared between processes in that VM, so processes must make
sure not to accidentally clash in handle ID selection. They are also
used in TcpChannel to mean a specific <spanstyle="font-style: italic">instance</span> of a TCP
connection, so if you are likely to want to reconnect individual
flows, use different values for <spanclass="RktSym">id</span>.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-listener-port))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-listener~3f))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._struct~3atcp-listener))"></a><aname="(def._((lib._marketplace/drivers/tcp-bare..rkt)._tcp-listener))"></a><spantitle="Provided from: marketplace/drivers/tcp-bare"><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-listener%29%29"class="RktValDef RktValLink"data-pltdoc="x">tcp-listener</a></span></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">port</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:prefab</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">port</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">integer-in</span><spanclass="hspace"> </span><spanclass="RktVal">0</span><spanclass="hspace"> </span><spanclass="RktVal">65535</span><spanclass="RktPn">)</span></td></tr></table></blockquote></div><divclass="SIntrapara">Describes a local half-connection with a user-assigned port number.
Use this to describe server sockets.</div></p><h5>4.2.3<tt> </tt><aname="(part._.Opening_an_outbound_connection)"></a>Opening an outbound connection</h5><p>Choose a <spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-handle%29%29"class="RktValLink"data-pltdoc="x">tcp-handle</a></span>, and then create endpoints as follows:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let%29%29"class="RktStxLink"data-pltdoc="x">let</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktPn">(</span><spanclass="RktSym">local</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-handle%29%29"class="RktValLink"data-pltdoc="x">tcp-handle</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">some-unique-value</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">remote</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-address%29%29"class="RktValLink"data-pltdoc="x">tcp-address</a></span><spanclass="hspace"> </span><spanclass="RktVal">"the.remote.host.example.com"</span><spanclass="hspace"> </span><spanclass="RktVal">5999</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._transition%2Fno-state%29%29"class="RktStxLink"data-pltdoc="x">transition/no-state</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._publisher%29%29"class="RktStxLink"data-pltdoc="x">publisher</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-channel%29%29"class="RktValLink"data-pltdoc="x">tcp-channel</a></span><spanclass="hspace"> </span><spanclass="RktSym">local</span><spanclass="hspace"> </span><spanclass="RktSym">remote</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-channel%29%29"class="RktValLink"data-pltdoc="x">tcp-channel</a></span><spanclass="hspace"> </span><spanclass="RktSym">remote</span><spanclass="hspace"> </span><spanclass="RktSym">local</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.
response to the presence of the endpoints. When the endpoints are
deleted (or the process exits), the TCP driver will notice the absence
and will close the underlying TCP socket.</p><p>For a complete example, see <ahref="Examples.html#%28part._chat-client-example%29"data-pltdoc="x">TCP chat client</a>.</p><h5>4.2.4<tt> </tt><aname="(part._.Accepting_inbound_connections)"></a>Accepting inbound connections</h5><p>Choose a port number, and then create an <spanstyle="font-style: italic">observer</span> endpoint as
follows:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-publishers%29%29"class="RktStxLink"data-pltdoc="x">observe-publishers</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-channel%29%29"class="RktValLink"data-pltdoc="x">tcp-channel</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-listener%29%29"class="RktValLink"data-pltdoc="x">tcp-listener</a></span><spanclass="hspace"> </span><spanclass="RktVal">5999</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-conversation%29%29"class="RktStxLink"data-pltdoc="x">match-conversation</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-channel%29%29"class="RktValLink"data-pltdoc="x">tcp-channel</a></span><spanclass="hspace"> </span><spanclass="RktSym">them</span><spanclass="hspace"> </span><spanclass="RktSym">us</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29"class="RktStxLink"data-pltdoc="x">_</a></span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-presence%29%29"class="RktStxLink"data-pltdoc="x">on-presence</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%29%29"class="RktStxLink"data-pltdoc="x">spawn</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">chat-session</span><spanclass="hspace"> </span><spanclass="RktSym">them</span><spanclass="hspace"> </span><spanclass="RktSym">us</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><p>The use of <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-publishers%29%29"class="RktStxLink"data-pltdoc="x">observe-publishers</a></span> here indicates that this endpoint isn’t
monitoring demand for such exchanges. The TCP driver uses the unusual
<spanclass="RktVal">'</span><spanclass="RktVal">everything</span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Interest.Type%29%29"class="RktValLink"data-pltdoc="x">InterestType</a></span> to monitor the presence of
<spanclass="RktVal">'</span><spanclass="RktVal">observer</span>s, and creates listening TCP server sockets in
communicating on the newly-arrived socket.</p><p>To illustrate the code for handling a newly-arrived connection,</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define%29%29"class="RktStxLink"data-pltdoc="x">define</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">chat-session</span><spanclass="hspace"> </span><spanclass="RktSym">them</span><spanclass="hspace"> </span><spanclass="RktSym">us</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._transition%2Fno-state%29%29"class="RktStxLink"data-pltdoc="x">transition/no-state</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-channel%29%29"class="RktValLink"data-pltdoc="x">tcp-channel</a></span><spanclass="hspace"> </span><spanclass="RktSym">them</span><spanclass="hspace"> </span><spanclass="RktSym">us</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-absence%29%29"class="RktStxLink"data-pltdoc="x">on-absence</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._quit%29%29"class="RktValLink"data-pltdoc="x">quit</a></span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-message%29%29"class="RktStxLink"data-pltdoc="x">on-message</a></span><spanclass="hspace"> </span><spanclass="RktPn">[</span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-channel%29%29"class="RktValLink"data-pltdoc="x">tcp-channel</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29"class="RktStxLink"data-pltdoc="x">_</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29"class="RktStxLink"data-pltdoc="x">_</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/bytestrings.html#%28def._%28%28quote._~23~25kernel%29._bytes~3f%29%29"class="RktValLink"data-pltdoc="x">bytes?</a></span><spanclass="hspace"> </span><spanclass="RktSym">data</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spancl
<spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/bytestrings.html#%28def._%28%28quote._~23~25kernel%29._bytes~3f%29%29"class="RktValLink"data-pltdoc="x">bytes?</a></span>.</p><h5>4.2.6<tt> </tt><aname="(part._.Sending_data)"></a>Sending data</h5><p>Send data with</p><blockquoteclass="SCodeFlow"><p><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp-channel%29%29"class="RktValLink"data-pltdoc="x">tcp-channel</a></span><spanclass="hspace"> </span><spanclass="RktSym">local-address</span><spanclass="hspace"> </span><spanclass="RktSym">remote-address</span><spanclass="hspace"> </span><spanclass="RktSym">subpacket</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></p></blockquote><p>where, as for receiving data, the <spanclass="RktSym">subpacket</span> is either
<spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/port-ops.html#%28def._%28%28quote._~23~25kernel%29._eof%29%29"class="RktValLink"data-pltdoc="x">eof</a></span> or a <spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/bytestrings.html#%28def._%28%28quote._~23~25kernel%29._bytes~3f%29%29"class="RktValLink"data-pltdoc="x">bytes?</a></span>.</p><h4>4.3<tt> </tt><aname="(part._timer__typed_and_untyped_)"></a>timer (typed and untyped)</h4><p>For examples of the use of the timer driver, see uses of
<spanclass="RktSym">set-timer</span> and <spanclass="RktSym">timer-expired</span> in
Marketplace-based DNS resolver</a>.</p><h4>4.4<tt> </tt><aname="(part._udp__typed_and_untyped_)"></a>udp (typed and untyped)</h4><p>For examples of the use of the UDP driver, see uses of
Marketplace-based DNS resolver</a>.</p><divclass="navsetbottom"><spanclass="navleft"> </span><spanclass="navright"> <ahref="low-level-interface.html"title="backward to "3 Low-level interface""data-pltdoc="x">← prev</a> <ahref="index.html"title="up to "Marketplace: Network-Aware Programming""data-pltdoc="x">up</a> <ahref="Management_and_Monitoring.html"title="forward to "5 Management and Monitoring""data-pltdoc="x">next →</a></span> </div></div></div><divid="contextindicator"> </div></body></html>