|
18 | 18 | -include("rabbit.hrl"). |
19 | 19 |
|
20 | 20 | -export([is_ssl/1, ssl_info/1, controlling_process/2, getstat/2, |
21 | | - recv/1, async_recv/3, port_command/2, setopts/2, send/2, close/1, |
22 | | - maybe_fast_close/1, sockname/1, peername/1, peercert/1, |
| 21 | + recv/1, async_recv/3, port_command/2, getopts/2, setopts/2, send/2, |
| 22 | + close/1, maybe_fast_close/1, sockname/1, peername/1, peercert/1, |
23 | 23 | connection_string/2]). |
24 | 24 |
|
25 | 25 | %%--------------------------------------------------------------------------- |
|
34 | 34 | -type(ok_val_or_error(A) :: rabbit_types:ok_or_error2(A, any())). |
35 | 35 | -type(ok_or_any_error() :: rabbit_types:ok_or_error(any())). |
36 | 36 | -type(socket() :: port() | #ssl_socket{}). |
| 37 | +-type(opts() :: [{atom(), any()} | |
| 38 | + {raw, non_neg_integer(), non_neg_integer(), binary()}]). |
37 | 39 |
|
38 | 40 | -spec(is_ssl/1 :: (socket()) -> boolean()). |
39 | 41 | -spec(ssl_info/1 :: (socket()) |
|
49 | 51 | -spec(async_recv/3 :: |
50 | 52 | (socket(), integer(), timeout()) -> rabbit_types:ok(any())). |
51 | 53 | -spec(port_command/2 :: (socket(), iolist()) -> 'true'). |
52 | | --spec(setopts/2 :: (socket(), [{atom(), any()} | |
53 | | - {raw, non_neg_integer(), non_neg_integer(), |
54 | | - binary()}]) -> ok_or_any_error()). |
| 54 | +-spec(getopts/2 :: (socket(), [atom() | {raw, |
| 55 | + non_neg_integer(), |
| 56 | + non_neg_integer(), |
| 57 | + non_neg_integer() | binary()}]) |
| 58 | + -> ok_val_or_error(opts())). |
| 59 | +-spec(setopts/2 :: (socket(), opts()) -> ok_or_any_error()). |
55 | 60 | -spec(send/2 :: (socket(), binary() | iolist()) -> ok_or_any_error()). |
56 | 61 | -spec(close/1 :: (socket()) -> ok_or_any_error()). |
57 | 62 | -spec(maybe_fast_close/1 :: (socket()) -> ok_or_any_error()). |
@@ -126,6 +131,11 @@ port_command(Sock, Data) when ?IS_SSL(Sock) -> |
126 | 131 | port_command(Sock, Data) when is_port(Sock) -> |
127 | 132 | erlang:port_command(Sock, Data). |
128 | 133 |
|
| 134 | +getopts(Sock, Options) when ?IS_SSL(Sock) -> |
| 135 | + ssl:getopts(Sock#ssl_socket.ssl, Options); |
| 136 | +getopts(Sock, Options) when is_port(Sock) -> |
| 137 | + inet:getopts(Sock, Options). |
| 138 | + |
129 | 139 | setopts(Sock, Options) when ?IS_SSL(Sock) -> |
130 | 140 | ssl:setopts(Sock#ssl_socket.ssl, Options); |
131 | 141 | setopts(Sock, Options) when is_port(Sock) -> |
|
0 commit comments