Proprer thread synchronization; reading input by "datagrams" (instead of as much as fits into the buffer) to get responsiveness.