According to the documentation it has to be inet:hostname() which is string(), which in elixir means char_list, so your hostname has to be 'example.com'. Alternatively you can also use the c-sigil (~c[example.com])
@NobbZ I actually looked in the docs and didn’t see this solution. Is it mentioned somewhere on this page: http://erlang.org/doc/man/gen_tcp.html ? Are these the docs you were referring to?
[other types omitted since they are unimportant here]
inet:hostname() (which is :inet.hostname in elixir syntax) is defined as follows:
hostname() = atom() | string()
Erlangs string() type is equal to elixirs charlist type.
charlists can be created using the charlist literal, which is an single-quoted “string”. Also one can use the c and C sigils to create them, when one wants to be a little bit more explicit.
And as @PatNowak correctly tells, you can convert anything implementing List.Chars by passing it to Kernel.to_charlist/1