Call to accept() does not time out when setting SO_RCVTIMEO on a socket

Bob Bishop rb at gid.co.uk
Thu Dec 8 13:50:05 UTC 2016


Hi,

> On 8 Dec 2016, at 12:41, Dimitri Staessens <dimitri.staessens at intec.ugent.be> wrote:
> 
> Dear devs,
> 
> I'm trying to get an accept() call to time out using setsockopt.
> 
> On Linux, the example below terminates:
> 
> [dstaesse at phoneutria]$ gcc accept_st.c -o accept_st
> [dstaesse at phoneutria]$ ./accept_st
> Timeout is 0:100000.
> Check is 0:103333.
> Accept returned: Resource temporarily unavailable.
> Accept returned: Resource temporarily unavailable.
> Accept returned: Resource temporarily unavailable.
> Bye.
> 
> On FreeBSD 11.0-RELEASE however, it hangs on the accept() forever.


accept() doesn’t work like that on *BSD. Set the socket non-blocking and then accept() returns EWOULDBLOCK if there is nothing to accept.

> Is this a known issue?
> 
> Thanks for your help,
> 
> Dimitri
> 
> --- example source:
> [snip]
> -- 
> Dimitri Staessens
> Ghent University - imec
> Dept. of Information Technology (INTEC)
> Internet Based Communication Networks and Services
> Technologiepark 15
> 9052 Zwijnaarde
> T: +32 9 331 48 70
> F: +32 9 331 48 99

--
Bob Bishop
rb at gid.co.uk






More information about the freebsd-bugs mailing list