file:sendfile/2 over unix domain socket

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

file:sendfile/2 over unix domain socket

Michael Buhot
I'm getting an {error, badarg} result from file:sendfile/2 when the socket argument was originally accepted from a unix domain socket.
The elixir script below demonstrates the problem:

require Logger

File.rm("local.sock")
File.write!("tmp.txt", "Hello World\n")

{:ok, socket} = :gen_tcp.listen(0, [:binary, packet: :line, active: false, ip: {:local, "local.sock"}])
#  {:ok, socket} = :gen_tcp.listen(4000, [:binary, packet: :line, active: false])

{:ok, client} = :gen_tcp.accept(socket)
case :file.sendfile("tmp.txt", client) do
    {:ok, sent} ->
        Logger.info("sent #{sent} bytes")
    error ->
        Logger.error(inspect(error))
end

Swapping the call to gen_tcp:listen with the version using tcp port 4000 works successfully.  
Should file:sendfile/2 work with unix domain sockets?

Thanks

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions