Socket accept - “Too many open files”

后端 未结 13 1798
情歌与酒
情歌与酒 2020-11-28 02:48

I am working on a school project where I had to write a multi-threaded server, and now I am comparing it to apache by running some tests against it. I am using autobench to

相关标签:
13条回答
  • 2020-11-28 03:22

    TCP has a feature called "TIME_WAIT" that ensures connections are closed cleanly. It requires one end of the connection to stay listening for a while after the socket has been closed.

    In a high-performance server, it's important that it's the clients who go into TIME_WAIT, not the server. Clients can afford to have a port open, whereas a busy server can rapidly run out of ports or have too many open FDs.

    To achieve this, the server should never close the connection first -- it should always wait for the client to close it.

    0 讨论(0)
提交回复
热议问题