我试图使用tcp套接字发送元组,我使用gen_tcp:send(套接字,{elem1,elem2}),但我收到了这个错误,“输出端口上的坏值'tcp_inet‘”,有人能告诉我如何通过套接字发送元组吗?
谢谢你的回复。
发布于 2016-06-01 04:32:37
第二个参数必须是一个数据包:
Packet = string() | binary() | HttpPacket
HttpPacket = HttpRequest
| HttpResponse
| HttpHeader
| http_eoh
| HttpError
HttpRequest = {http_request, HttpMethod, HttpUri, HttpVersion}
HttpResponse =
{http_response, HttpVersion, integer(), HttpString}
HttpHeader =
{http_header,
integer(),
HttpField,
Reserved :: term(),
Value :: HttpString}
...在您的例子中,{elem1,elem2}确实匹配这些类型中的任何一个,并且得到了错误。发送任意项的通常方法是先序列化它:term_to_binary(YourTerm)
并在接收到它时反序列化:binary_to_term(ReceivedBinary)
https://stackoverflow.com/questions/37559354
复制相似问题