aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_tcp_transport.erl
diff options
context:
space:
mode:
authorAndrew Thompson <[email protected]>2012-04-06 13:14:54 -0400
committerAndrew Thompson <[email protected]>2012-04-06 13:24:02 -0400
commit06a2d636bce7a0494b960eae574fc092d25fcd7a (patch)
treecfbf0b5a432ca68cd3688a4bab7263da03f35c4e /src/cowboy_tcp_transport.erl
parent95e05d822f46e791a919f4e966879b4827989669 (diff)
downloadcowboy-06a2d636bce7a0494b960eae574fc092d25fcd7a.tar.gz
cowboy-06a2d636bce7a0494b960eae574fc092d25fcd7a.tar.bz2
cowboy-06a2d636bce7a0494b960eae574fc092d25fcd7a.zip
Add sockname/1 to the TCP and SSL transports
Diffstat (limited to 'src/cowboy_tcp_transport.erl')
-rw-r--r--src/cowboy_tcp_transport.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cowboy_tcp_transport.erl b/src/cowboy_tcp_transport.erl
index 82d193b..f197dd1 100644
--- a/src/cowboy_tcp_transport.erl
+++ b/src/cowboy_tcp_transport.erl
@@ -20,7 +20,7 @@
-module(cowboy_tcp_transport).
-export([name/0, messages/0, listen/1, accept/2, recv/3, send/2, setopts/2,
- controlling_process/2, peername/1, close/1]).
+ controlling_process/2, peername/1, close/1, sockname/1]).
%% @doc Name of this transport API, <em>tcp</em>.
-spec name() -> tcp.
@@ -104,3 +104,10 @@ peername(Socket) ->
-spec close(inet:socket()) -> ok.
close(Socket) ->
gen_tcp:close(Socket).
+
+%% @doc Get the local address and port of a socket
+%% @see inet:sockname/1
+-spec sockname(inet:socket())
+ -> {ok, {inet:ip_address(), inet:port_number()}} | {error, atom()}.
+sockname(Socket) ->
+ inet:sockname(Socket).