sanjay nayak has asked for the wisdom of the Perl Monks concerning the following question:
The config.txt contains:#! usr/bin/perl -w use warnings; use IO::Socket::INET; use strict; use Config::Tiny; my ($DATA,$text, $msg); $/=undef; open CONFIGFILE, "config.txt" or die $!; DATA=<CONFIGFILE>; print $DATA; # Create a config my $Config = Config::Tiny->new(); # Open the config, replace with read and $DATA with filename $Config = Config::Tiny->read_string( $DATA ); # see perldoc Config::Tiny my $s = $Config->{_}; my $MySocket=new IO::Socket::INET->new ( LocalPort => $s->{LocalPort}, Proto => $s->{Proto} ); $MySocket or die "Can't create socket ($!)\n"; $MySocket->autoflush(1); print "Server started :Ready For Packet To Receive:\n"; for(;;) { $MySocket->recv($text,128);#Recv chomp $text; if($text ne "q") { print "\nReceived message:$text"; } print "\nEnter message to send to client or q to quit: "; if(defined($msg=<STDIN>)) { chomp $msg; if($msg ne "q") { $MySocket->send($msg); print "waiting for response: \n"; } else { $MySocket->send("q"); print "\n Server Exited"; exit 1; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why my socket is not send and receive data???
by rodion (Chaplain) on Aug 19, 2006 at 14:37 UTC | |
by ikegami (Patriarch) on Aug 19, 2006 at 18:24 UTC | |
|
Re: Why my socket is not send and receive data???
by choocroot (Friar) on Aug 19, 2006 at 15:53 UTC | |
by chromatic (Archbishop) on Aug 19, 2006 at 19:08 UTC | |
by choocroot (Friar) on Aug 19, 2006 at 20:02 UTC | |
|
Re: Why my socket is not send and receive data???
by ikegami (Patriarch) on Aug 19, 2006 at 18:26 UTC | |
|
Re: Why my socket is not send and receive data???
by jeanluca (Deacon) on Aug 19, 2006 at 11:13 UTC |