从套接字以及另一个 Erlang 进程接收
在 Erlang 进程中,我如何从 ssl 套接字接收数据,同时使用接收原语从另一个 erlang 进程接收数据?
这个想法是将来自套接字的内容转发到另一个进程;和向后。
到目前为止,我唯一的选择是使用一些时间从两端接收,然后切换。当然,这会延迟在一个接口上接收的消息的处理,同时从另一个接口接收消息。你有其他方法可以做到这一点吗?如果 Erlang 让我使用一个进程从套接字接收,并使用另一个进程发送到套接字就好了……
in an Erlang process, how could i receive from an ssl socket, and at the same time receive from another erlang process with the receive primitive?
the idea is to forward what comes from the socket to another process; and backwards.
my only option so far is to use some time receiving from each end, then switch. that, of course, will delay the processing of the messages received on one interface, while receiving from the other one. do you see any other way to do this? if only Erlang would let me use one process to receive from the socket, and another one to send to the socket...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定我理解你的问题;无论如何,您可以在接收语句中包含多个“子句”,因此当从任何一方接收某些内容时,它都会“解锁”:
重要的是您需要以可以区分 SSL 和处理消息的方式格式化消息与模式匹配。
Not sure I understand your question; anyway, you can have multiple "clauses" in a receive statement, so it becomes "unblocked" when receiving something from either side:
The important thing is that you need to format your messages in a way that you can differentiate between SSL and process messages with pattern matching.
无论如何,您将通过
receive
语句在进程中从(例如)HTTP_Client 接收消息。您将能够轻松地描述“对话”:HTTP_Client“对话”的
{http, {RequestId, Result}}
请参阅 此处了解更多详细信息。
You'll anyhow receive the message from (e.g.) an HTTP_Client in a process through the
receive
statement. You'll be able to delineate the "conversations" easily:{http, {RequestId, Result}}
for the HTTP_Client "conversations"See here for more details.