Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

help me on socket programming

by bh_perl (Monk)
on Jul 12, 2013 at 03:28 UTC ( [id://1043865]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1043865]
Approved by hdb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-04-25 15:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found