R socketConnection/make.socket():有什么方法可以继续监听()?
[免责声明:我对套接字的了解非常生疏,而且我刚刚进入 R,所以如果我错过了一些完全明显的东西,请指出!]
如果我理解用于创建和管理套接字的(文档很少)R 函数,即 socketConnection
和 make.socket
,似乎在创建服务器套接字 (server=TRUE
) 时,以下内容的道德等价物是执行:
s = socket(yada yada);
listen(s, ...);
s2 = accept(s, ...);
close(s, ...);
现在我可以使用 s2
,但无法循环处理积压的 s
传入连接。这或多或少是正确的吗?在处理第一个连接后,有什么方法可以继续监听并继续处理其他传入连接吗?
[Disclaimer: my knowledge of sockets is very rusty, and I'm just getting into R, so if I missed something completely obvious, please point it out!]
If I understand the (sparsely-documented) R functions for creating and managing sockets, namely socketConnection
and make.socket
, it appears that when creating a server socket (server=TRUE
), the moral equivalent of the following is carried out:
s = socket(yada yada);
listen(s, ...);
s2 = accept(s, ...);
close(s, ...);
and now I can work with s2
but can't loop to deal with a backlog of incoming connections to s
. Is this more-or-less right? Is there any way to keep listening and continue to deal with additional incoming connections after handling the first?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也想知道这个问题的答案! ...但与此同时,我至少可以建议一个有一些限制的解决方法:
如果您知道有多少客户端将连接,那么以下应该可行。
在服务器上:
在每个客户端上:
I'd like to know the answer to this one too! ...but in the meantime I can at least suggest a work-around with some limitations:
If you can know HOW MANY clients will connect, then the following should work.
On the server:
On each client:
不,您可以触摸
s1
上的积压日志。窗口 1:
窗口 2:
窗口 3:
窗口 1:
No, you can touch the back-log on
s1
.Window 1:
Window 2:
Window 3:
Window 1: