How to detect the TCP connection with SELECT?

xiaoxiao2021-03-06  152

Read signal trigger, but receives 0 bytes of data

-------------------------------------------------- -------------

To determine a connection as an example

FD_SET Read_Set;

Struct Timeval T_o;

...

FD_ZERO (& Read_set);

FD_SET (Lsockfd, & Read_set);

T_O.tv_sec = n; / * Timeout Six * /

RET = SELECT (LSOCKFD 1, & Read_set, NULL, NULL, & T_O);

IF (RET == 1)

{Count = Recv (LSOCKFD, BUF, LEN, 0);

IF (count == 0) | | (count == -1))))

{

/ * Both cases can be considered to be link close * /

}

...

}

...

转载请注明原文地址:https://www.9cbs.com/read-127647.html

New Post(0)