need help with perl code

Thread Starter

Ataleph

Joined Apr 20, 2009
31
Dear All,
Can anyone explain me what the following PERL code does:
#!/usr/bin/perl
use IO::Socket;
$hostname = "10.4.46.34";
$hostport = 5025;
$instr_sock = IO::Socket::INET->new(PeerAddr => $hostname,
PeerPort => $hostport,
Proto => 'tcp');
die "Can not connect to FW Socket Server at $hostname
(port $hostport)\n"
unless $instr_sock;
$instr_sock->autoflush(1);
In particular I don't understand what the "5025" is. Is it port number of a physical or virtual port? Is it a port of LAN connection or one of an instrument connection?
Thanks.
 
Im not to faimilar with Peral, but I think its saying its going to be connecting to that Port. So you might need to foward that port if its going to be something for others to see. If its lan than you dont need to foward the port. Just make sure your firewall lets that port.
 

Thread Starter

Ataleph

Joined Apr 20, 2009
31
Actually this code is running on Linox station which is connected through LAN to windows station which in turn is controlling some Agilent equipment called "Parallel BERT" via VXI interface. What I want to do is to connect other Agilent device (real time scope) to the same windows station via GPIB interface and control it remotely running similar code on my Linox station. For this purpose I need to understand how that connection is done and emulate it.
 

AlexR

Joined Jan 16, 2008
732
I don't know too much about pearl but it appears to be setting up a TCP connection to IP address 10.4.46.34 TCP port 5025. And yes this is a virtual port since all TCP ports are virtual ports.

All TCP connections are specified by the local IP address and TCP port number and the target IP address and a TCP port number. The TCP protocol in the local host obviously knows its own IP address and the port number so it just has to be told the remote IP address and TCP port number.

I suggest you do a Google on "TCP Tutorial" to get a basic understanding of how TCP works.
 

AlexR

Joined Jan 16, 2008
732
That right. In the receiving box there will be some process running that listens for connection requests on TCP port 5025 and sends that data to the relevant program.
 
Last edited:
Top