我目前正在处理SSL套接字。我把它设为:
{ok, LSocket} = ssl:listen(443, [{packet, http},
{reuseaddr, true},
{active, false},
{certfile, "mycert.pem"},
{keyfile, "mykey.pem"}]).
但是当我将套接字传递给另一个应该处理连接的进程时,通过调用:
ssl:getopts(LSocket, [packet]).
我得到了:
{ok,[{packet,0}]}
而不是:
{ok,[{packet,http}]
不是0表示“原始数据包?”为什么会这样?
答案 0 :(得分:0)
你自己编译过Erlang吗?可能你已经搞砸了一些加密模块。 尝试使用Erlang Solutions的预编译15B02:https://www.erlang-solutions.com/downloads/download-erlang-otp
您演示的代码在传递给另一个进程时可以正常工作:
Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9.2 (abort with ^G)
1> {ok, LSocket} = ssl:listen(9443, [{packet, http}, {reuseaddr, true}, {active, false}, {certfile, "priv/ssl/ssl.crt"}, {keyfile, "priv/ssl/ssl.key"}]).
{ok,{sslsocket,new_ssl,
{#Port<0.719>,
{config,{ssl_options,[],verify_none,
{#Fun<ssl.1.38762831>,[]},
false,false,undefined,1,<<"priv/ssl/ssl.crt">>,undefined,
<<"priv/ssl/ssl.key">>,undefined,[],undefined,<<>>,
undefined,undefined,
[<<0,...>>,<<...>>|...],
#Fun<ssl.0.38762831>,true,...},
[{packet,http},{reuseaddr,true},{active,false}],
{socket_options,list,http,0,0,false},
[{reuseaddr,true},
{packet_size,0},
{packet,0},
{header,0},
{active,false},
{mode,binary}],
{gen_tcp,tcp,tcp_closed,tcp_error}}}}}
2>
2> ssl:getopts(LSocket, [packet]).
{ok,[{packet,http}]}
3> spawn(fun() -> ssl:getopts(LSocket, [packet]) end).
<0.42.0>
4> spawn(fun() -> error_logger:info_msg(ssl:getopts(LSocket, [packet])) end).
<0.44.0>
5>
=INFO REPORT==== 1-Nov-2012::06:07:15 ===
ERROR: {ok,[{packet,http}]} - []