bh_perl has asked for the wisdom of the Perl Monks concerning the following question:

hi..

I want to collect data from legacy switch to our server using XOT. The XOT port is 1998. All the data will be keep into specific filename.

I test the script, but its did not display the received packet or header packet.

Could somebody help me, how could i got the data and this is my coding

#!/usr/bin/perl use IO::Socket; $socket = new IO::Socket::INET ( PeerAddr => '19.25.15.15', PeerPort => 1998, Proto => 'tcp', ) or die "Couldn't connect to Server\n"; while (1) { $socket->recv($recv_data,10); print $recv_data."\n"; $send_data = <STDIN>; $socket->send($send_data); }

Thank you

Replies are listed 'Best First'.
Re: help me on socket programming
by NetWallah (Canon) on Jul 12, 2013 at 05:14 UTC
    Try using 'telnet' to connect to the socket, and see if it sends a prompt immediately on connection.

    If it does not, your program may need to send data out to the server first.

                 My goal ... to kill off the slow brain cells that are holding me back from synergizing my knowledge of vertically integrated mobile platforms in local cloud-based content management system datafication.

      hi...

      I am able to ping and telnet to that IP. But why my socket programming did not display anything. Its suppose to display the received data.

      Please guide me

        To expand what NetWallh said, when you telnet to port 1998 with the command below, does it send a response, or do you need to send a request in order to get a response?

        telnet $SWITCH_ADDRESS 1998

        print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
Re: help me on socket programming
by Anonymous Monk on Jul 12, 2013 at 04:16 UTC
    It seems like your while loop has no meaning. Maybe you are confused with a server socket.

      hi..

      If I want to pull data from the legacy switch to our server. Is it means my server is a CLIENT and the switch is SERVER right ?. If correct, it is mean that I have to write client socket programming on my server right ?

      Please correct me