diff options
author | Kim Alvefur <zash@zash.se> | 2013-12-23 17:55:41 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-12-23 17:55:41 +0100 |
commit | 3e156487cff0779f075a765451cacb2a7c47b52c (patch) | |
tree | f168330bb6ef7081313505a401411ce04f24dd77 /net/server_select.lua | |
parent | 5c25cdaa77b2868e99e6ff97d7fd4fe34e115773 (diff) | |
download | prosody-3e156487cff0779f075a765451cacb2a7c47b52c.tar.gz prosody-3e156487cff0779f075a765451cacb2a7c47b52c.zip |
net.server_{select,event}: addclient: Add argument for overriding socket type
Diffstat (limited to 'net/server_select.lua')
-rw-r--r-- | net/server_select.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/net/server_select.lua b/net/server_select.lua index 91b8b01f..1ce3c8c7 100644 --- a/net/server_select.lua +++ b/net/server_select.lua @@ -930,7 +930,7 @@ local wrapclient = function( socket, ip, serverport, listeners, pattern, sslctx return handler, socket end -local addclient = function( address, port, listeners, pattern, sslctx ) +local addclient = function( address, port, listeners, pattern, sslctx, typ ) local err if type( listeners ) ~= "table" then err = "invalid listener table" @@ -941,12 +941,19 @@ local addclient = function( address, port, listeners, pattern, sslctx ) elseif sslctx and not has_luasec then err = "luasec not found" end + if not typ then + typ = "tcp" + end + local create = luasocket[typ] + if type( create ) ~= "function" then + err = "invalid socket type" + end if err then out_error( "server.lua, addclient: ", err ) return nil, err end - local client, err = luasocket.tcp( ) + local client, err = create( ) if err then return nil, err end |