does anyone know if you can set a timeout for a listening socket? I know that you can use a timeout for a send/recv action with SO_RCVTIMEO and SO_SNDTIMEO (through setsockopt) but in my case I need to set that timeout for a socket in a listen state. If no connection is established in X time, I closed the socket. Do you know any socket option to get that?
Thank you.
select()function which is for that purpose. If the socket is read(able) means that you can use theaccept()without blocking. Ifselect()return 0 means the timeout has elapsed. - ja_mesa