Both ways worked, but the problem is that it's still blocking my script to display things on the command-line. When I Ctrl+C to terminate the execution I get the usual "user break" message and all the things I tried to display on the command-line.<div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Nov 12, 2012 at 12:00 PM, Greg Hendershott <span dir="ltr"><<a href="mailto:greghendershott@gmail.com" target="_blank">greghendershott@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">> When I try to use do-not-return I get this error: bonsai.rkt:22:3:<br>
> do-not-return: unbound identifier in module<br>
<br>
</div>To use it, you would need to require the module that provides it:<br>
<br>
(require web-server/web-server)<br>
<br>
(Which I found by searching the docs for `do-not-return', and getting this:<br>
<a href="http://docs.racket-lang.org/web-server-internal/web-server.html#(def._((lib._web-server/web-server..rkt)._do-not-return))" target="_blank">http://docs.racket-lang.org/web-server-internal/web-server.html#(def._((lib._web-server/web-server..rkt)._do-not-return))</a><br>
<div class="im">)<br>
<br>
> Then I tried read-line, which worked, but it blocks the console output so<br>
> I'll only see the things that my script is sending to the console after I<br>
> hit Enter and finish the program. Is there a asynchronous way of doing this?<br>
<br>
</div>It sounds like you should use `do-not-return' as Jay recommended.<br>
<br>
If you don't want to require all of web-server to get it, the<br>
definition is simply this:<br>
<br>
(define (do-not-return)<br>
(semaphore-wait (make-semaphore 0)))<br>
<div class="im HOEnZb"><br>
<br>
On Mon, Nov 12, 2012 at 8:42 AM, Nathan Campos <<a href="mailto:nathanpc@dreamintech.net">nathanpc@dreamintech.net</a>> wrote:<br>
</div><div class="HOEnZb"><div class="h5">> When I try to use do-not-return I get this error: bonsai.rkt:22:3:<br>
> do-not-return: unbound identifier in module<br>
><br>
> Then I tried read-line, which worked, but it blocks the console output so<br>
> I'll only see the things that my script is sending to the console after I<br>
> hit Enter and finish the program. Is there a asynchronous way of doing this?<br>
><br>
><br>
><br>
> On Mon, Nov 12, 2012 at 1:55 AM, Greg Hendershott<br>
> <<a href="mailto:greghendershott@gmail.com">greghendershott@gmail.com</a>> wrote:<br>
>><br>
>> If I understand correctly you simply need your main Racket thread to<br>
>> wait, for example, after your main thread calls your `start-server':<br>
>><br>
>> (start-server)<br>
>> (displayln "Server started. Press ENTER to quit.")<br>
>> (read-line)<br>
>> ;; End of your main RKT file<br>
>><br>
>><br>
>> On Sun, Nov 11, 2012 at 8:39 PM, Nathan Campos <<a href="mailto:nathanpc@dreamintech.net">nathanpc@dreamintech.net</a>><br>
>> wrote:<br>
>> > I'm having some fun with tcp-listen with Racket, here's the simple start<br>
>> > server function that I'm using:<br>
>> ><br>
>> > #lang racket<br>
>> ><br>
>> > (define start-server<br>
>> > (lambda ([port 8080])<br>
>> > (current-custodian server-custodian)<br>
>> > ; Caps at 50 connections at the same time<br>
>> > (define listener (tcp-listen port 50 #t))<br>
>> > (define (loop)<br>
>> > (accept-and-handle listener)<br>
>> > (loop))<br>
>> > (define t (thread loop))<br>
>> > (lambda ()<br>
>> > (kill-thread t)<br>
>> > (tcp-close listener))<br>
>> > (fprintf (current-output-port) "Server started listening at ~a"<br>
>> > port)))<br>
>> ><br>
>> > It was running great on DrRacket, but when I tried to run it under<br>
>> > racket<br>
>> > (the command-line executable) it shows the sever started message and<br>
>> > quits,<br>
>> > so the server doesn't keep running. Is there anyway to make racket wait<br>
>> > until it's process gets killed or the user types something?<br>
>> ><br>
>> > Best Regards,<br>
>> > Nathan Campos<br>
>> ><br>
>> > ____________________<br>
>> > Racket Users list:<br>
>> > <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
>> ><br>
><br>
><br>
><br>
> ____________________<br>
> Racket Users list:<br>
> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
><br>
</div></div></blockquote></div><br></div>