开发者

the select() socket system call on mac osx taking a long time for reads

开发者 https://www.devze.com 2023-01-12 16:37 出处:网络
We\'re developing a cross-platform network application that needs to send and receive data over TCP. On linux we are using select() to wait on both send and receive to make sure that the socket is rea

We're developing a cross-platform network application that needs to send and receive data over TCP. On linux we are using select() to wait on both send and receive to make sure that the socket is ready. However, on OSX the select for read takes an absurd amount of time to return -- over 20 seconds. select() isn't timing out -- our tim开发者_运维知识库eout is 60 seconds and the data is coming back, it's just ridiculously slow. This only happens for reads, not sends. The network appears to be fine (again, the linux machine on the same network does not seem to have the same issues).

Is anyone aware of any caveats using socket programming in OSX?


Have you tried kqueue(2) on OSX and epoll(7) on Linux? These are much more performant and flexible, though platform-specific, interfaces for I/O event handling. You might also take a look at libevent that abstracts all this for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消