[erlang-questions] Unimplemented {buffer, integer()} option in ssl module - bug?

Ingela Andin ingela.andin@REDACTED
Fri Dec 2 11:28:05 CET 2016


2016-12-01 12:37 GMT+01:00 Richard Jones <rj@REDACTED>:

> The {buffer, integer()} option from gen_tcp is useful for breaking up
> incoming data into manageable sizes, especially when in {packet, line}
> mode.
>
> The docs suggest (kinda) that the gen_tcp options should also work
> when connecting via the ssl module, but this isn'

always the case -
> the buffer option is silently ignored by ssl:connect
>

Actually it is not ignored it just is not has no noticeable affect to you.

Is this

a bug? Tested on erl 17, 18, 19
>
>
For this option to work as expected for you it needs to be emulated by the
ssl process as are packet related options. So it is a missing feature.

Regards  Ingela Erlang/OTP- team



> Examples follow using netcat/socat as a server. Note that gen_tcp
> breaks the incoming data into 3 messages, ssl delivers as one large
> message.
>
> Non-SSL example:
> ----------------
>
> $ echo "12345678901234567890123" | nc -l 1234
>
> 1> {ok, _} = gen_tcp:connect("localhost", 1234, [
>  binary,
>  {packet, line},
>  {buffer, 10},
>  {active, true}]).
>
> {ok,#Port<0.1180>}
>
> 2> flush().
>
> Shell got {tcp,#Port<0.1180>,<<"1234567890">>}
> Shell got {tcp,#Port<0.1180>,<<"1234567890">>}
> Shell got {tcp,#Port<0.1180>,<<"123\n">>}
> Shell got {tcp_closed,#Port<0.1180>}
> ok
>
> SSL example:
> ------------
>
> $ echo "12345678901234567890123" | socat STDIO
> OPENSSL-LISTEN:1234,reuseaddr,cert=/some.pem,cafile=/some.crt,verify=0
>
> 1> {ok, _} = ssl:connect("localhost", 1234, [
>   binary,
>   {packet, line},
>   {buffer, 10},
>   {active, true},
>   {verify, verify_none}]).
>
> {ok,{sslsocket,{gen_tcp,#Port<0.1179>,tls_connection,
>                         undefined},
>                <0.54.0>}}
>
> 2> flush().
>
> Shell got {ssl,{sslsocket,{gen_tcp,#Port<0.1179>,tls_connection,
> undefined},
>                           <0.54.0>},
>                <<"12345678901234567890123\n">>}
> Shell got {ssl_closed,
>               {sslsocket,
>                   {gen_tcp,#Port<0.1179>,tls_connection,undefined},
>                   <0.54.0>}}
> ok
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161202/473d96fa/attachment.htm>


More information about the erlang-questions mailing list