Software /
code /
prosody
Diff
net/server_select.lua @ 5965:99d55f12a26f
net.server_{select,event}: addclient: Add argument for overriding socket type
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 23 Dec 2013 17:55:41 +0100 |
parent | 5961:5745bb2b6890 |
child | 5966:958ad646c0f2 |
line wrap: on
line diff
--- a/net/server_select.lua Wed Dec 18 19:00:24 2013 -0500 +++ b/net/server_select.lua Mon Dec 23 17:55:41 2013 +0100 @@ -930,7 +930,7 @@ 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 @@ 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