Comparison

net/server_event.lua @ 6791:e813e8cf6046

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 20 Aug 2015 13:05:22 +0200
parent 6481:dbc72cd1332e
parent 6782:ec172dbe9d14
child 6820:40d50c239564
comparison
equal deleted inserted replaced
6776:4412a2307c89 6791:e813e8cf6046
756 end 756 end
757 end 757 end
758 local create = socket[typ or "tcp"] 758 local create = socket[typ or "tcp"]
759 if type( create ) ~= "function" then 759 if type( create ) ~= "function" then
760 return nil, "invalid socket type" 760 return nil, "invalid socket type"
761 end 761 end
762 local client, err = create() -- creating new socket 762 local client, err = create() -- creating new socket
763 if not client then 763 if not client then
764 debug( "cannot create socket:", err ) 764 debug( "cannot create socket:", err )
765 return nil, err 765 return nil, err
766 end 766 end
767 client:settimeout( 0 ) -- set nonblocking 767 client:settimeout( 0 ) -- set nonblocking
768 local res, err = client:connect( addr, serverport ) -- connect 768 local res, err = client:connect( addr, serverport ) -- connect
769 if res or ( err == "timeout" or err == "Operation already in progress" ) then 769 if res or ( err == "timeout" or err == "Operation already in progress" ) then
770 if client.getsockname then 770 if client.getsockname then
771 addr = client:getsockname( ) 771 addr = client:getsockname( )
772 end 772 end
773 local interface = wrapclient( client, addr, serverport, listener, pattern, sslctx ) 773 local interface = wrapclient( client, addr, serverport, listener, pattern, sslctx )
774 debug( "new connection id:", interface.id ) 774 debug( "new connection id:", interface.id )
775 return interface, err 775 return interface, err
776 else 776 else
777 debug( "new connection failed:", err ) 777 debug( "new connection failed:", err )