【问题标题】:How to differentiate between each client connections in nanomsg socket library如何区分 nanomsg 套接字库中的每个客户端连接
【发布时间】:2014-10-21 09:33:21
【问题描述】:

我正在使用 nanomsg 库

int sock = nn_socket (AF_SP, NN_PAIR);

assert (nn_bind (sock, url) >= 0);

现在我想知道如果客户端连接,如何区分服务器中的每个连接。

在常规 Linux TCP Socket 中,我们将在每个连接接受时获得新的套接字 fd, 我期待在 nanomsg 中有类似的东西。

在下面的链接中我尝试使用 - Pair (Two Way Radio)

http://tim.dysinger.net/posts/2013-09-16-getting-started-with-nanomsg.html

【问题讨论】:

    标签: linux sockets nanomsg


    【解决方案1】:

    我不认为你可以默认。

    消息进来,每当消息进来,你处理它。没有关于哪个客户端连接或消息来自何处的其他数据。

    因此,我的建议是让每个客户端在每条消息的开头通过 UUID 来标识自己,或者将消息包装成类似 JSON 的格式,客户端使用一个密钥来标识自己。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-27
      • 2019-04-02
      • 2019-11-19
      • 2015-02-08
      • 2021-10-22
      • 1970-01-01
      • 2011-03-22
      • 1970-01-01
      相关资源
      最近更新 更多