简体   繁体   English

在Elixir中设置gen_tcp的参数

[英]set parameters of gen_tcp in Elixir

I'm trying to accept data through a TCP connection in Elixir using Erlang gen_tcp 我正在尝试使用Erlang gen_tcp通过Elixir中的TCP连接接受数据

{:ok, socket} = :gen_tcp.connect("127.0.0.1" ,2000,[:binary, {:packet, 0}])
receive_data(Socket, [])

But this isn't working due to bad arguments of connect . 但这由于connect错误论点而无法正常工作。 How to set binary and packet values in Elixir? 如何在Elixir中设置二进制和数据包值?

Here It is explained about parameter meanings. 在此对参数含义进行说明。 But I need support to set parameters in Elixir. 但是我需要支持在Elixir中设置参数。

Looking at gen_tcp's documentation, you can't set a packet option on a connection. 查看gen_tcp的文档,您无法在连接上设置数据包选项。 http://erlang.org/doc/man/gen_tcp.html#type-connect_option http://erlang.org/doc/man/gen_tcp.html#type-connect_option

The problem is not the parameters, which are correct, but the address. 问题不是正确的参数,而是地址。 To call into erlang, you need to use a character list 要调用erlang,您需要使用字符列表

{:ok, socket} = :gen_tcp.connect('127.0.0.1', 2000, [:binary, packet: 0])

Note '127.0.0.1' instead of "127.0.0.1" . 注意'127.0.0.1'而不是"127.0.0.1"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM