non blocking socket select returns 1 after connect

前端 未结 2 445
遇见更好的自我
遇见更好的自我 2020-12-21 10:29

First of all I would like to say that this is another problem than this one: Similar but not the same

My code looks like this:

struct addrinfo hints,         


        
2条回答
  •  佛祖请我去吃肉
    2020-12-21 10:53

    I don't know where in the man pages you see that it should time out.

    If there is no firewall dropping the packets, the connection will be refused pretty fast (one packet from your host, one packet reply). So an "event" on the connecting socket will come in as soon as the reset is received. This will wake up select, with (at least) one active socket.

    The first attempt to read from or write to that socket will return the underlying connect error.

提交回复
热议问题