Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: UDP Server doesn't receive before newline

by zwon (Abbot)
on Dec 05, 2012 at 02:17 UTC ( #1007179=note: print w/replies, xml ) Need Help??

in reply to UDP Server doesn't receive before newline

UDP doesn't have buffering. Buffering happens on the server side -- stdio library buffers output. Try:

print "$datagram\n";

Replies are listed 'Best First'.
Re^2: UDP Server doesn't receive before newline
by nitin1704 (Sexton) on Dec 05, 2012 at 04:25 UTC
    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)?
      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 :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007179]
[holli]: ah, chatterbox right
[marto]: it's a normal HTML form, with some hidden input fields
[holli]: forgot that thing exists for a moment.
LanX welcome to the twilight zone ...
[Eily]: LanX well since the onion is your eye you should see it everywhere
[marto]: sounds eye watering
[LanX]: oh your talking about my pic?
[Eily]: marto #SoSad
[holli]: duh
[marto]: I expect you to take a nice photo in Glasgow to replace this one :P

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2017-12-14 16:18 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (398 votes). Check out past polls.