in reply to Why my socket is not send and receive data???

Why are you globally enabling "slurp mode" (with $/=undef) ?

This disable the "readline mode" when you use $msg=<STDIN>, so Perl will wait forever until it gets a End-Of-File. It means, that entering your message and hitting ENTER will not give you back the message in $msg, so you'll have to type ^D (CTRL+D) in order to process your entry.

If you just want to "slurp" your CONFIGFILE (and nothing else), you should first open CONFIGFILE, then locally disable $/ :
open CONFIGFILE, "config.txt" or die $!; { local $/; $/ = undef; $DATA=<CONFIGFILE>; } print $DATA;
That way, $/ remains in default "line mode" for your read from <STDIN> (see perlvar for details on scope with $/).

Beside this "slurp mode" problem, your code seems to run well on my machine with "nc -u localhost 1234" as a client.

Replies are listed 'Best First'.
Re^2: Why my socket is not send and receive data???
by chromatic (Archbishop) on Aug 19, 2006 at 19:08 UTC
    local $/; $/ = undef;

    Have you had problems with local not undefining values? I think that second line is a no-op.

      No, but I'm used to always explicitly define the value of this variable when I want to change it's behaviour in a block.

      But you're right, my "$/ = undef" is redundant here.