elixir-socket icon indicating copy to clipboard operation
elixir-socket copied to clipboard

How can I specify the raw option IP_FREEBIND when connecting to a socket?

Open building39 opened this issue 8 years ago • 2 comments

I tried `Socket.TCP.connect("localhost", 80, {:raw, 6, 15, :true}) and received:

** (FunctionClauseError) no function clause matching in Access.get/3

The following arguments were given to Access.get/3:

    # 1
    {:raw, 6, 15, true}

    # 2
    :timeout

    # 3
    nil

Attempted function clauses (showing 5 out of 5):

    def get(%{__struct__: struct} = container, key, default)
    def get(map, key, default) when is_map(map)
    def get(list, key, default) when is_list(list) and is_atom(key)
    def get(list, key, _default) when is_list(list)
    def get(nil, _key, default)

(elixir) lib/access.ex:302: Access.get/3
(socket) lib/socket/tcp.ex:105: Socket.TCP.connect/3

building39 avatar Oct 19 '17 19:10 building39

What would the code look like with gen_tcp?

meh avatar Oct 20 '17 16:10 meh

{:ok, s} = :gen_tcp.connect('localhost', 80, [{:raw, 0, 15, <<1>>}, {:ip, {10, 138, 69, 63}}])

building39 avatar Oct 20 '17 17:10 building39