M
mastermagrath
Hi all,
I've a problem with a simple socket client/server script which has bee
described in several threads already but alas none of them have been
able to help me.
Its the problem wherein any text i write to the server socket doesn't
get outpu until i close the client connection. All of the threads on
the subject all suggest the same thing i.e. make sure you send a
newline or carriage return or both with the string in question, i've
tried everything, i've tried sending:
"text to send\n"
"text to send\r\n"
"text to send\n\r"
Nothing works, nothing gets processed from the servers end until i
close down the client end, only then does the text get printed in the
server. I even tried sending an explicit EOF character with the string
but even that doesn't work!
I've dumped the very simple code below if anyone could take a look. Has
anyone got a very simple example script similar to this which works on
XP acitve state v5.8.8???
SERVER CODE:
$server = IO::Socket::INET->new(
Listen => 5,
LocalAddr => 'localhost',
LocalPort => 9000,
Proto => 'tcp');
die "ERROR: $!\n" unless $server;
print "Waiting on connections...\n";
while($client = $server->accept()){
print "Connection made, reading data...\n";
print <$client>;
print "Connection closed...\n";
}
$server->close();
CLIENT CODE:
$sock = IO::Socket::INET->new(
PeerAddr => 'localhost',
PeerPort => 9000,
Proto => 'tcp');
die "Error: $!\n" unless $sock;
$sock->autoflush(1);
print $sock "take me to your leader\r\n";
$answer=<$sock>;
print $answer;
close($sock);
I've a problem with a simple socket client/server script which has bee
described in several threads already but alas none of them have been
able to help me.
Its the problem wherein any text i write to the server socket doesn't
get outpu until i close the client connection. All of the threads on
the subject all suggest the same thing i.e. make sure you send a
newline or carriage return or both with the string in question, i've
tried everything, i've tried sending:
"text to send\n"
"text to send\r\n"
"text to send\n\r"
Nothing works, nothing gets processed from the servers end until i
close down the client end, only then does the text get printed in the
server. I even tried sending an explicit EOF character with the string
but even that doesn't work!
I've dumped the very simple code below if anyone could take a look. Has
anyone got a very simple example script similar to this which works on
XP acitve state v5.8.8???
SERVER CODE:
$server = IO::Socket::INET->new(
Listen => 5,
LocalAddr => 'localhost',
LocalPort => 9000,
Proto => 'tcp');
die "ERROR: $!\n" unless $server;
print "Waiting on connections...\n";
while($client = $server->accept()){
print "Connection made, reading data...\n";
print <$client>;
print "Connection closed...\n";
}
$server->close();
CLIENT CODE:
$sock = IO::Socket::INET->new(
PeerAddr => 'localhost',
PeerPort => 9000,
Proto => 'tcp');
die "Error: $!\n" unless $sock;
$sock->autoflush(1);
print $sock "take me to your leader\r\n";
$answer=<$sock>;
print $answer;
close($sock);