Diff

net/server_event.lua @ 6818:ae9d1289a868

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 6817:07f43c7aa059
child 6819:ffb2b5e31456
line wrap: on
line diff
--- a/net/server_event.lua	Wed Dec 18 18:11:17 2013 -0500
+++ b/net/server_event.lua	Mon Dec 23 17:55:41 2013 +0100
@@ -742,12 +742,19 @@
 		--function handleclient( client, ip, port, server, pattern, listener, _, sslctx )  -- creates an client interface
 	end
 
-	function addclient( addr, serverport, listener, pattern, sslctx )
+	function addclient( addr, serverport, listener, pattern, sslctx, typ )
 		if sslctx and not has_luasec then
 			debug "need luasec, but not available"
 			return nil, "luasec not found"
 		end
-		local client, err = socket.tcp()  -- creating new socket
+		if not typ then
+			typ = "tcp"
+		end
+		local create = socket[typ]
+		if type( create ) ~= "function"  then
+			return nil, "invalid socket type"
+		end
+		local client, err = create()  -- creating new socket
 		if not client then
 			debug( "cannot create socket:", err )
 			return nil, err