Software /
code /
prosody
Comparison
net/server_select.lua @ 6814:936f969bf783
net/server_select: addclient: Check arguments
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Wed, 18 Dec 2013 17:55:03 -0500 |
parent | 6813:b1615fa62e59 |
child | 6815:46546d57f639 |
comparison
equal
deleted
inserted
replaced
6813:b1615fa62e59 | 6814:936f969bf783 |
---|---|
941 end | 941 end |
942 return handler, socket | 942 return handler, socket |
943 end | 943 end |
944 | 944 |
945 local addclient = function( address, port, listeners, pattern, sslctx ) | 945 local addclient = function( address, port, listeners, pattern, sslctx ) |
946 local err | |
947 if type( listeners ) ~= "table" then | |
948 err = "invalid listener table" | |
949 elseif type ( addr ) ~= "string" then | |
950 err = "invalid address" | |
951 elseif type( port ) ~= "number" or not ( port >= 0 and port <= 65535 ) then | |
952 err = "invalid port" | |
953 elseif sslctx and not has_luasec then | |
954 err = "luasec not found" | |
955 end | |
956 if err then | |
957 out_error( "server.lua, addclient: ", err ) | |
958 return nil, err | |
959 end | |
960 | |
946 local client, err = luasocket.tcp( ) | 961 local client, err = luasocket.tcp( ) |
947 if err then | 962 if err then |
948 return nil, err | 963 return nil, err |
949 end | 964 end |
950 client:settimeout( 0 ) | 965 client:settimeout( 0 ) |