guocw998
2009-11-26 16:49 阅读 217
已采纳

socket API:what is “the peer”?

SO_KEEPALIVE:
When the keepalive option is set for a TCP socket and no data has been exchanged across the socket in either direction for 2 hours (NOTE: the actual value is implementation dependent),TCP automatically sends a keepalive probe to the peer. This probe is a TCP segment to which the peer must respond.
One of three responses is expected:
1. The peer responds with the expected ACK. The application is not notified (since everything is OK). TCP will send another probe following another 2 hours of inactivity.
2. The peer responds with an RST, which tells the local TCP that the peer host has crashed and rebooted. The socket is closed.
3. There is no response from the peer. The socket is closed.

The purpose of this option is to detect if the peer host crashes.

Valid only for TCP socket: SocketImpl

从上面一段英文,what is “the peer”?
希望给一个比较专业的解释:

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx 2009-11-26 16:55

    socket的一方称呼另一方,即: the peer.你可以理解为服务端。

    点赞 评论 复制链接分享
  • wanghaolovezlq wanghaolovezlq 2009-11-26 17:10

    为 TCP 套接字设置 keepalive 选项时,如果在 2 个小时(注:实际值与实现有关)内在任意方向上都没有跨越套接字交换数据,则 TCP 会自动将 keepalive 探头发送到同位体。此探头是同位体必须响应的 TCP 段。期望的响应为以下三种之一:1. 同位体通过期望的 ACK 响应。不通知应用程序(因为一切正常)。在另一个 2 小时的不活动时间过后,TCP 将发送另一个探头。2. 同位体通过 RST 响应,通知本地 TCP 同位体主机已崩溃并重新启动。套接字被关闭。3. 同位体没有响应。套接字被关闭。 此选项的目的是检测同位体主机是否崩溃。 仅对 TCP 套接字(SocketImpl)有效。

    peer叫同位体

    点赞 评论 复制链接分享
  • wanghaolovezlq wanghaolovezlq 2009-11-26 17:12

    同位体(peer):一个同位体是可以理解协议的任何实体。所以,一个同位体可以是一个处理器、机器或用户。

    可以参考下
    http://www.ibm.com/developerworks/cn/java/l-jxta/index.html

    点赞 评论 复制链接分享

相关推荐