[erlang-questions] R16B and ssl sockets

bog495@REDACTED bog495@REDACTED
Wed May 29 10:06:49 CEST 2013



Hello

I have the following functions that work perfectly in R14B04:

recv_frame_ssl(S, N, SslRecvTimeout) ->
%%      io:format("SslRecvTimeout = ~p~n", [SslRecvTimeout]),
        {ok, Header} = ssl:recv(S, 4, SslRecvTimeout),
        <<Length:32/big>> = Header,
        {ok, Data} = ssl:recv(S, Length - 4, SslRecvTimeout),

        <<Data1/binary>> = Data,
        
        {ok, binary_to_list(Data1)}.
        
send_frame_ssl(Sock, Data) ->
        
        DataBin = unicode:characters_to_binary(Data),
        HeaderLen = erlang:size(DataBin) + 4,
        
%%      error_logger:info_msg("SEND-FRAME:[~p]:~n:~p:~n:~p:~n:~p~n:~p~n", 
[self(), Data, DataBin, HeaderLen, <<HeaderLen:32/big>>]),
        
        ssl:send(Sock, <<HeaderLen:32/big>>),
        ssl:send(Sock, <<DataBin/binary>>).


However in R16 the code fails with:{error, socket_closed_remotely} .

This is because the server correctly receives and decodes the packet from 
the client, in recv_ssl_frame/3,

but when the server must send response to the client, in function 
send_frame_ssl/2 , the packet is no more correctly assembled 
and the client closes the connection because does not receives the header 
which is the total length of the packet and hence does not know the length 
of data to be read from the socket
and hence the error on the server side {error, socket_closed_remotely} .

In R14B* this is working as expected, however in R15 and R16 does not.

What am I missing, what should I do in order to send to the client a 
correctly formatted  packet ?

Thank you in advanced,

Bogdan




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130529/6151560c/attachment.htm>


More information about the erlang-questions mailing list