<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>There&#39;s a function called do-not-return (search for it), that waits on an anonymous empty semaphore, that the Web server uses. <br>
<br>Sent from my iPhone</div><div><br>On 2012/11/11, at 18:44, Nathan Campos &lt;<a href="mailto:nathanpc@dreamintech.net">nathanpc@dreamintech.net</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div style="font-family:arial,sans-serif;font-size:13px">
I&#39;m having some fun with tcp-listen with Racket, here&#39;s the simple start server function that I&#39;m using:</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px"><span style="white-space:pre-wrap">        #lang racket</span><br></div><div style="font-family:arial,sans-serif;font-size:13px"><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap"><br>


</span></div><div style="font-family:arial,sans-serif;font-size:13px"><div><span style="white-space:pre-wrap">        </span>(define start-server</div><div><span style="white-space:pre-wrap">        </span>(lambda ([port 8080])</div><div>

<span style="white-space:pre-wrap">        </span>  (current-custodian server-custodian)</div><div><span style="white-space:pre-wrap">                </span>; Caps at 50 connections at the same time</div><div><span style="white-space:pre-wrap">                </span>(define listener (tcp-listen port 50 #t))</div>

<div><span style="white-space:pre-wrap">                </span>(define (loop)</div><div><span style="white-space:pre-wrap">                </span>  (accept-and-handle listener)</div><div><span style="white-space:pre-wrap">                </span>  (loop))</div><div>

<span style="white-space:pre-wrap">                </span>(define t (thread loop))</div><div><span style="white-space:pre-wrap">                </span>(lambda ()</div><div><span style="white-space:pre-wrap">                </span>  (kill-thread t)</div><div><span style="white-space:pre-wrap">                </span>  (tcp-close listener))</div>

<div><span style="white-space:pre-wrap">        </span>  (fprintf (current-output-port) &quot;Server started listening at ~a&quot; port)))</div></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">

It was running great on DrRacket, but when I tried to run it under racket (the command-line executable) it shows the sever started message and quits, so the server doesn&#39;t keep running. Is there anyway to make racket wait until it&#39;s process gets killed or the user types something?</div>

<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Best Regards,</div><div style="font-family:arial,sans-serif;font-size:13px"><span style="white-space:pre-wrap">  Nathan Campos</span></div>

</div></blockquote><blockquote type="cite"><div><span>____________________</span><br><span>  Racket Users list:</span><br><span>  <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a></span><br>
</div></blockquote></body></html>