<div dir="ltr"><br><div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-01 12:37 GMT+01:00 Richard Jones <span dir="ltr"><<a href="mailto:rj@metabrew.com" target="_blank">rj@metabrew.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The {buffer, integer()} option from gen_tcp is useful for breaking up<br>
incoming data into manageable sizes, especially when in {packet, line}<br>
mode.<br>
<br>
The docs suggest (kinda) that the gen_tcp options should also work<br>
when connecting via the ssl module, but this isn' </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">always the case -<br>
the buffer option is silently ignored by ssl:connect<br></blockquote><br></div><div class="gmail_quote">Actually it is not ignored it just is not has no noticeable affect to you. <br></div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Is this </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">a bug? Tested on erl 17, 18, 19<br>
<br></blockquote><div><br></div><div>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. <br></div><div><br></div><div>Regards  Ingela Erlang/OTP- team   <br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Examples follow using netcat/socat as a server. Note that gen_tcp<br>
breaks the incoming data into 3 messages, ssl delivers as one large<br>
message.<br>
<br>
Non-SSL example:<br>
----------------<br>
<br>
$ echo "12345678901234567890123" | nc -l 1234<br>
<br>
1> {ok, _} = gen_tcp:connect("localhost", 1234, [<br>
 binary,<br>
 {packet, line},<br>
 {buffer, 10},<br>
 {active, true}]).<br>
<br>
{ok,#Port<0.1180>}<br>
<br>
2> flush().<br>
<br>
Shell got {tcp,#Port<0.1180>,<<"<wbr>1234567890">>}<br>
Shell got {tcp,#Port<0.1180>,<<"<wbr>1234567890">>}<br>
Shell got {tcp,#Port<0.1180>,<<"123\n">><wbr>}<br>
Shell got {tcp_closed,#Port<0.1180>}<br>
ok<br>
<br>
SSL example:<br>
------------<br>
<br>
$ echo "12345678901234567890123" | socat STDIO<br>
OPENSSL-LISTEN:1234,reuseaddr,<wbr>cert=/some.pem,cafile=/some.<wbr>crt,verify=0<br>
<br>
1> {ok, _} = ssl:connect("localhost", 1234, [<br>
  binary,<br>
  {packet, line},<br>
  {buffer, 10},<br>
  {active, true},<br>
  {verify, verify_none}]).<br>
<br>
{ok,{sslsocket,{gen_tcp,#Port<<wbr>0.1179>,tls_connection,<br>
                        undefined},<br>
               <0.54.0>}}<br>
<br>
2> flush().<br>
<br>
Shell got {ssl,{sslsocket,{gen_tcp,#<wbr>Port<0.1179>,tls_connection,<wbr>undefined},<br>
                          <0.54.0>},<br>
               <<"12345678901234567890123\n"><wbr>>}<br>
Shell got {ssl_closed,<br>
              {sslsocket,<br>
                  {gen_tcp,#Port<0.1179>,tls_<wbr>connection,undefined},<br>
                  <0.54.0>}}<br>
ok<br>
______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
</blockquote></div><br></div></div></div>