Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

perl send and receive scripts

Status
Not open for further replies.

codelady7

Programmer
Mar 2, 2006
9
US
Hi group --

I'm working more on perl scripts to send and receive HL7 messages.

Attached are two very simple scripts that I took from O'Reilly Advanced Perl Programming book (pgs 192 - 193). I'm working with two systems, one XP, the other RedHat 9.0.

The scripts work if:
1. sending/receiving scripts both running on linux box
2. sending/receiving scripts both running on XP
2. sending from linux to XP

BUT -- if I try to send from XP to the linux box, I get a message that the socket could not be defined due to an unknown error.

If I run the send script using the trace, this seems to be the line that sends it to the error routine:

IO::Socket::INET::configure(C:/Perl/lib/IO/Socket/INET.pm:204):
204: return _error($sock, $!, $@ || "Timeout")
205: unless @raddr;


Here are the scripts:

# receiver

use IO::Socket;
use Sys::Hostname;

$host = hostname();

$sock = new IO::Socket::INET (LocalHost => $host,
LocalPort => 10500,
Proto => 'tcp',
Listen => 5,
Reuse => 1);

die "Couldn't create socket $! \n" unless $sock;
print "connected...\n";
while ($new_sock = $sock->accept()) {
while (defined ($buf = <$new_sock>)) {
print $buf;
}
}


close($sock);

*********************************************************

# send test

use IO::Socket;
$sock = new IO::Socket::INET (PeerAddr => '192.168.1.210',
PeerPort => 10500,
Proto => 'tcp');

die "Socket not created: $! \n" unless $sock;

foreach (1 .. 10) {
print $sock "hi $_: here is a message.\n";
}

close ($sock);


Can anyone offer any clues? The perl I'm running on XP was just installed from activestate...says it's version 5.8.7. On the RedHat side, I have a fresh install, version 5.8.8.

Thanks in advance!

-- Chris Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top