in reply to Re: UDP Server doesn't receive before newline
in thread UDP Server doesn't receive before newline

That worked. Thanks! Why doesn't the stdio library buffer output like this when I do a normal print statement (instead of doing it like this in a socket-recv() scenario)?
  • Comment on Re^2: UDP Server doesn't receive before newline

Replies are listed 'Best First'.
Re^3: UDP Server doesn't receive before newline
by zwon (Abbot) on Dec 05, 2012 at 05:45 UTC
    Socket is irrelevant. Try:
    perl -e'while(1) { print "Datagram"; sleep 1; }'
    check man stdio for your system. Mine (GNU/Linux) says:
    Output streams that refer to terminal devices are always line buffered by default; pending output to such streams is written automatically whenever an input stream that refers to a terminal device is read. In cases where a large amount of computation is done after printing part of a line on an output terminal, it is necessary to fflush(3) the standard output before going off and computing so that the output will appear.
      Thanks again zwon :)