Home > Archive > PERL Beginners > September 2004 > server is numb?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Christian Stalp 2004-09-28, 8:56 am |
| Hello together,
I just tryed to make a simple Socket-Connection with a client and a server
which are connected with each other over localhost.
the server:
#!/usr/bin/perl
use IO::Socket;
use strict;
my $server_port = 3434;
my $server;
my $client;
my $in_line;
$server = IO::Socket::INET-> new ( LocalPort => $server_port,
Type => SOCK_STREAM,
Reuse => 1,
Listen => SOMAXCONN )
or die "unable to start server ! $@\n";
while ( $client = $server->accept () )
{
$in_line = <CLIENT>;
print "$in_line \n";
}
close ( $server );
__END_
and the client:
#!/usr/bin/perl
use IO::Socket;
use strict;
my $remote_host = "localhost";
my $remote_port = 3434;
my $socket;
my $data = "test";
$socket = IO::Socket::INET->new ( PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => "tcp",
Type => SOCK_STREAM )
or die "unable to establishe a connection !\n";
$socket-> send ( $data , $flags ) or die "could not send!\n";
close ( $socket );
__END_
I expact, that the data-string is send by the client to the server. When it
reaches the server, the server put it out, and keep on listening.
But the server does nothing at all, its numb?!?
What did I omitted? How I get the flags? With fcntl ?
Gruss Christian
| |
| Christian Stalp 2004-09-28, 8:56 am |
| Okay okay, it shold call:
while ( $client = $server->accept () )
{
print "$client \n";
}
close ( $server );
__END_
And so it works, but not as I need. The output is
IO::Socket::INET=GLOB(0x81848d0)
Gruss Christian
--
Christian Stalp
Institut für Medizinische Biometrie, Epidemiologie und Informatik (IMBEI)
Obere Zahlbacher Straße 69
55131 Mainz
Tel.: 06131/ 17-6852
E-Mail: stalp@imbei.uni-mainz.de
Internet: www.imbei.de
| |
| Jeff 'japhy' Pinyan 2004-09-28, 8:56 am |
| On Sep 28, Christian Stalp said:
>$socket-> send ( $data , $flags ) or die "could not send!\n";
To send data to the socket, just print() to it:
print $socket "$data\n";
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart
|
|
|
|
|