+ -
当前位置:首页 → 问答吧 → 请教各位大虾 关于LINUX SOCKET CLOSE的问题

请教各位大虾 关于LINUX SOCKET CLOSE的问题

时间:2011-10-30

来源:互联网

在某种情况下我会长时间阻塞在CLOSE(sockfd);上 请教要如何解决

作者: anaven   发布时间: 2011-10-30

通常端口关闭须等待一段时间,如果设置了SO_REUSEADDR则该端口是可复用的,关闭后如果有新连接,则该端口会再次打开。但不清楚LZ说的某种情况是什么

作者: fenggui321   发布时间: 2011-10-30


  If fildes refers to a socket, close() shall cause the socket to be destroyed. If the socket is in connection-mode, and the SO_LINGER option is set
  for the socket with non-zero linger time, and the socket has untransmitted data, then close() shall block for up to the current linger interval
  until all data is transmitted.

设置过SO_LINGER吧。

作者: qq120848369   发布时间: 2011-10-30