If I use the standard gen_tcp:accept/1, gen_tcp:recv/2, gen_tcp:send/2 on the socket, sendfile works as expected.
But not with a socket handled by prim_inet. Why?
When using the prim_inet API you have to be careful with what you
remove. In this case you have to call
`erlang:port_set_data(CSock,inet_tcp)` after accepting the socket. The
port data is used by erlang code to figure out which type of socket
the port represents.
> If I use the standard gen_tcp:accept/1, gen_tcp:recv/2, gen_tcp:send/2 on the socket, sendfile works as expected.
> But not with a socket handled by prim_inet. Why?
> Thanks for your help.
> Regards,
> Zabrane
> On Aug 8, 2012, at 11:00 AM, Lukas Larsson wrote:
>> Hi!
>> There are a couple of reasons why this might not work. Could you show
>> me a small example of what you are trying to do?
>> Lukas
>> On Fri, Jul 27, 2012 at 6:57 PM, Zabrane Mickael <zabra...@gmail.com> wrote:
>>> Hi,
>>> Is there any reason why a client socket created from prim_inet
>>> do not work with the new file:sendfile fonction?
> When using the prim_inet API you have to be careful with what you
> remove. In this case you have to call
> `erlang:port_set_data(CSock,inet_tcp)` after accepting the socket. The
> port data is used by erlang code to figure out which type of socket
> the port represents.
> Lukas
> On Mon, Aug 13, 2012 at 12:06 AM, Zabrane Mickael <zabra...@gmail.com> wrote:
>> Hi Lukas,
>> If I use the standard gen_tcp:accept/1, gen_tcp:recv/2, gen_tcp:send/2 on the socket, sendfile works as expected.
>> But not with a socket handled by prim_inet. Why?
>> Thanks for your help.
>> Regards,
>> Zabrane
>> On Aug 8, 2012, at 11:00 AM, Lukas Larsson wrote:
>>> Hi!
>>> There are a couple of reasons why this might not work. Could you show
>>> me a small example of what you are trying to do?
>>> Lukas
>>> On Fri, Jul 27, 2012 at 6:57 PM, Zabrane Mickael <zabra...@gmail.com> wrote:
>>>> Hi,
>>>> Is there any reason why a client socket created from prim_inet
>>>> do not work with the new file:sendfile fonction?