<p><br>
On Sep 14, 2014 7:56 AM, "Matthew Flatt" <<a href="mailto:mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>> wrote:<br>
><br>
> It's possible that something is wrong with `sync` and TCP ports ---<br>
> although the test suite at least includes that combination --- but can<br>
> you provide a complete program?<br>
><br>
> For example, I'm interested in what `handle-rdy-to-send` does. In the<br>
> part that you show, the function will be triggered when one byte is<br>
> available on stdin. If `handle-rdy-to-send` tries to read more bytes<br>
> than are immediately available, then it can block; i.e., the blocking<br>
> part could be in `handle-rdy-to-send`, not in `sync`. That would also<br>
> explain why using `sync/timeout` doesn't change anything.</p>
<p>Actually, I know it's blocking in the sync (or sync/timeout) because the actual code is littered with immediately-flushed printf's, and there's one right before and one right after the sync call. I will try to put together a version to send you, though. Would you prefer it with the debug printf's stripped out?</p>
<p>Thanks, Brett S. </p>
<p>><br>
> Again, that's just an example of what might be wrong other than `sync`.<br>
> A complete program would let us sort out the possibilities.<br>
><br>
> At Sun, 14 Sep 2014 06:57:34 -0500, Brett Stahlman wrote:<br>
> > Hello,<br>
> ><br>
> > I have the following loop in a tcp client program that sends forms typed by<br>
> > user at the terminal to a listening server, and receives such forms typed by<br>
> > other clients (broadcast to all clients by the server).<br>
> ><br>
> > (define server-msg-evt (wrap-evt in handle-server-msg))<br>
> > (define rdy-to-send-evt (wrap-evt (standard-input-port) handle-rdy-to-send))<br>
> ><br>
> > (let loop ()<br>
> >   (sync rdy-to-send-evt server-msg-evt)<br>
> >   (loop))<br>
> ><br>
> > The problem is that the server-msg-evt isn't reliably ready when the server<br>
> > flushes a message. I know the messages are being sent and flushed properly<br>
> > by<br>
> > the server because if I type a new form on stdin and hit enter, I see the<br>
> > following sequence:<br>
> ><br>
> > 1. Client processes new stdin form in handle-rdy-to-send<br>
> > 2. Client loops and calls sync<br>
> > 3. The server-msg-evt is *immediately* ready, and client handles the<br>
> >    message in handle-server-msg.<br>
> > Note: The message handled in step 3 may have been sent long before, but<br>
> > the client remained blocked in sync until the (unrelated) stdin event<br>
> > unblocked it.<br>
> ><br>
> > The really weird part is that the client blocks in this manner even if I<br>
> > change the sync to a sync/timeout!<br>
> ><br>
> > Any clue as to what could be going on here? I'm running both client and<br>
> > server<br>
> > in a DOS box on a Windows 7 machine.<br>
> ><br>
> > Thanks,<br>
> > Brett Stahlman<br>
> > ____________________<br>
> >   Racket Users list:<br>
> >   <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br>
</p>