Handle error from inet:getopts
This commit is contained in:
parent
a024fc4dc9
commit
14b6f4624a
@ -272,18 +272,23 @@ create_hstate(Options, Role) ->
|
|||||||
Prologue, {S, E, RS, RE}).
|
Prologue, {S, E, RS, RE}).
|
||||||
|
|
||||||
check_gen_tcp(TcpSock) ->
|
check_gen_tcp(TcpSock) ->
|
||||||
{ok, TcpOpts} = inet:getopts(TcpSock, [mode, packet, active, header, packet_size]),
|
case inet:getopts(TcpSock, [mode, packet, active, header, packet_size]) of
|
||||||
Packet = proplists:get_value(packet, TcpOpts, 0),
|
{ok, TcpOpts} ->
|
||||||
Active = proplists:get_value(active, TcpOpts, 0),
|
Packet = proplists:get_value(packet, TcpOpts, 0),
|
||||||
Header = proplists:get_value(header, TcpOpts, 0),
|
Active = proplists:get_value(active, TcpOpts, 0),
|
||||||
PSize = proplists:get_value(packet_size, TcpOpts, undefined),
|
Header = proplists:get_value(header, TcpOpts, 0),
|
||||||
Mode = proplists:get_value(mode, TcpOpts, binary),
|
PSize = proplists:get_value(packet_size, TcpOpts, undefined),
|
||||||
case (Packet == 0 orelse Packet == raw) andalso (Active == true orelse Active == once)
|
Mode = proplists:get_value(mode, TcpOpts, binary),
|
||||||
andalso Header == 0 andalso PSize == 0 andalso Mode == binary of
|
case (Packet == 0 orelse Packet == raw)
|
||||||
true ->
|
andalso (Active == true orelse Active == once)
|
||||||
gen_tcp:controlling_process(TcpSock, self());
|
andalso Header == 0 andalso PSize == 0 andalso Mode == binary of
|
||||||
false ->
|
true ->
|
||||||
{error, {invalid_tcp_options, TcpOpts}}
|
gen_tcp:controlling_process(TcpSock, self());
|
||||||
|
false ->
|
||||||
|
{error, {invalid_tcp_options, TcpOpts}}
|
||||||
|
end;
|
||||||
|
Err = {error, _} ->
|
||||||
|
Err
|
||||||
end.
|
end.
|
||||||
|
|
||||||
gen_tcp_snd_msg(S = {TcpSock, _, _}, Msg) ->
|
gen_tcp_snd_msg(S = {TcpSock, _, _}, Msg) ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user