Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: help me on socket programming

by bh_perl (Monk)
on Jul 12, 2013 at 07:05 UTC ( #1043891=note: print w/replies, xml ) Need Help??

in reply to Re: help me on socket programming
in thread help me on socket programming


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

Replies are listed 'Best First'.
Re^3: help me on socket programming
by Utilitarian (Vicar) on Jul 12, 2013 at 08:37 UTC
    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."


      I have tried run the command as below and its look hang.

      >telnet 1998 Trying... Connected to Escape character is '^]'.

      I think this is the system scenario to do the data collection

      1. Sent request to the remote server with specific address.

      2. Remote server acknowledge with some info.

      3. Collect available data based on the information and save into temporary file.

      4. End connection

        There does not appear to be a stream of data to read coming from that port when you connected, usually you have to send a request in these circumstances and the response is then sent and the socket is closed by the remote host or an agreed end of data signal flag is sent (usually "OK" or ("NO"|"KO")) to indicate the end of the data stream.

        In this case you should perhaps print your request to the socket and process the data stream until end of data or end of response token.

        print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."


      Based on the trace packet, I found that my server using port 1998 and the remote server using port 61236.

      How could i write the socket program to connect from my port (1998) to remote system on port (61236).

      This is sample data trace:

      Sent request to remote system
      -------------------------------- TCP Header -------------------------- +-------- sport: 1998 --> dport: 61236 flags: PUSH ACK seq: 0xfd2fed0a urp: 0x0 chksum: 0xe16a data len: 519 ack: 0x2f975faf win: 0x1ed9 optlen: 0 -------------------------------- XOT --------------------------------- +--------

      Remote server acknowlegde
      -------------------------------- TCP Header -------------------------- +-------- sport: 61236 --> dport: 1998 flags: PUSH ACK seq: 0x2f975faf urp: 0x0 chksum: 0x1b data len: 7 ack: 0xfd2fef11 win: 0x8000 optlen: 0 -------------------------------- XOT --------------------------------- +-------- 0: 00 00 00 03 10 01 41 -- -- -- -- -- -- -- -- -- ......A........ +.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1043891]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2023-02-05 20:32 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (32 votes). Check out past polls.