http://qs321.pair.com?node_id=1043906


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

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."

Replies are listed 'Best First'.
Re^4: help me on socket programming
by bh_perl (Monk) on Jul 12, 2013 at 09:24 UTC

    hi...

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

    >telnet 19.25.15.15 1998 Trying... Connected to 19.25.15.15. 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."
Re^4: help me on socket programming
by bh_perl (Monk) on Jul 13, 2013 at 03:17 UTC

    hi...


    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........ +.