need help with perl code

Discussion in 'Computing and Networks' started by Ataleph, May 2, 2009.

  1. Ataleph

    Thread Starter Active Member

    Apr 20, 2009
    31
    0
    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.
     
  2. Siniter Fister

    Member

    Apr 25, 2009
    17
    0
    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.
     
  3. Ataleph

    Thread Starter Active Member

    Apr 20, 2009
    31
    0
    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.
     
  4. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    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.
     
  5. Siniter Fister

    Member

    Apr 25, 2009
    17
    0
    Ok so you have a linux box sending a request to a windows box saying hey dude let me in? That request being on Port 5025?
     
  6. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    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: May 6, 2009
Loading...