How to detect tcp connect closed? - TCP-IP

This is a discussion on How to detect tcp connect closed? - TCP-IP ; I want to wrap a TCPConnManager class to register several IP addresses of the TCP server. When a TCP connection is closed, the detection thread will automatically switch to establish a new TCP connection using another IP address. Would you ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: How to detect tcp connect closed?

  1. How to detect tcp connect closed?

    I want to wrap a TCPConnManager class to register several IP addresses
    of the TCP server. When a TCP connection is closed, the detection
    thread will automatically switch to establish a new TCP connection
    using another IP address.

    Would you please instruct me how to implement it?
    Thank you very much.

    Regards
    Allen Chen


  2. Re: How to detect tcp connect closed?

    On Jun 26, 11:31 pm, Allen wrote:

    > I want to wrap a TCPConnManager class to register several IP addresses
    > of the TCP server. When a TCP connection is closed, the detection
    > thread will automatically switch to establish a new TCP connection
    > using another IP address.


    > Would you please instruct me how to implement it?
    > Thank you very much.


    It depends upon what I/O model you choose to use (blocking, non-
    blocking, multi-threaded, select, I/O completion ports). Basically,
    the connection is closed normally by the other end or terminates due
    to an error, your next 'read' operation will inform you.

    So as long as you are trying to read data that arrives on the
    connection (by whatever mechanism you choose) you will be informed of
    any fatal errors that occur and are detected. Note that your protocol
    must make sure TCP can detect such errors. For example, if you never
    send any data, you are not guaranteed to be able to detect a loss of
    connectivity. (No data being sent means no operations to fail, so no
    failures.)

    DS


+ Reply to Thread