problams with IO::Socket::INET

Saar Ginzburski (SaarG@amdocs.com)
Tue, 27 Jan 1998 19:23:56 +0200


Hi,

I'm trying to create simple Client/Server application using the
IO::Socket package.

The SERVER script: 

###############################################################
use IO::Socket;
$sock = new IO::Socket::INET (LocalHost 	=> "localhost",
					LocalPort 	=> 8012,
					Proto		=> 'tcp',
					Listen	=> 5,
					Reuse		=> 1
					);
die "Socket could not be created. Reason: $!\n" unless $sock;
while ($new_sock = $sock->accept()) {
	while (defined ($buf = <$new_sock>)) {
		print $buf;
	}
}
close($sock);
###############################################################


The CLIENT script:

###############################################################
use IO::Socket;
$sock = new IO::Socket::INET (PeerHost => "localhost",
					PeerPort => 8012,
					Proto	   =>
getprotobyname("tcp")
					);
die "Socket could not be created. Reason: $!\n" unless $sock;
foreach (1..10) {
	print $sock "Msg $_: How are you?\n";
}
close ($sock);
###############################################################

The server script is all right and work properly, while I'm trying to
run the client script I got the following message:

	IO::Socket::INET: Bad peer address at .//client line 3
	Socket could not be created. Reason: Bad file number

I'm running the scripts under Windows NT4 and HP-UX10.
I'm using perl 5.004.

Any help will be appreciated


sincerely
Saar Ginzburski

CC - Infrastructre 
saarg@bigfoot.com
TN: 972-3-5762324