[racket] Possible bug involving sync on tcp ports

From: Brett Stahlman (brettstahlman at gmail.com)
Date: Sun Sep 14 07:57:34 EDT 2014

Hello,

I have the following loop in a tcp client program that sends forms typed by
user at the terminal to a listening server, and receives such forms typed by
other clients (broadcast to all clients by the server).

(define server-msg-evt (wrap-evt in handle-server-msg))
(define rdy-to-send-evt (wrap-evt (standard-input-port) handle-rdy-to-send))

(let loop ()
  (sync rdy-to-send-evt server-msg-evt)
  (loop))

The problem is that the server-msg-evt isn't reliably ready when the server
flushes a message. I know the messages are being sent and flushed properly
by
the server because if I type a new form on stdin and hit enter, I see the
following sequence:

1. Client processes new stdin form in handle-rdy-to-send
2. Client loops and calls sync
3. The server-msg-evt is *immediately* ready, and client handles the
   message in handle-server-msg.
Note: The message handled in step 3 may have been sent long before, but
the client remained blocked in sync until the (unrelated) stdin event
unblocked it.

The really weird part is that the client blocks in this manner even if I
change the sync to a sync/timeout!

Any clue as to what could be going on here? I'm running both client and
server
in a DOS box on a Windows 7 machine.

Thanks,
Brett Stahlman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140914/407b5637/attachment.html>

Posted on the users mailing list.