Software /
code /
prosody
Comparison
net/server_select.lua @ 9499:36e379f058c8
net.server: Swich method for connecting sockets with remotes
LuaSocket TCP sockets have have both :connect and :setpeername, which
are the exact same function, however UDP sockets only have :setpeername.
Switching to :setpeername allows most of this code to be generic wrt
TCP/UDP.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 12 Oct 2018 17:36:34 +0200 |
parent | 9495:89e05b118f6e |
child | 9574:03214e6e3272 |
child | 9634:f457edaab510 |
comparison
equal
deleted
inserted
replaced
9498:cc593002f2e2 | 9499:36e379f058c8 |
---|---|
1030 local client, err = create( ) | 1030 local client, err = create( ) |
1031 if err then | 1031 if err then |
1032 return nil, err | 1032 return nil, err |
1033 end | 1033 end |
1034 client:settimeout( 0 ) | 1034 client:settimeout( 0 ) |
1035 local ok, err = client:connect( address, port ) | 1035 local ok, err = client:setpeername( address, port ) |
1036 if ok or err == "timeout" or err == "Operation already in progress" then | 1036 if ok or err == "timeout" or err == "Operation already in progress" then |
1037 return wrapclient( client, address, port, listeners, pattern, sslctx ) | 1037 return wrapclient( client, address, port, listeners, pattern, sslctx ) |
1038 else | 1038 else |
1039 return nil, err | 1039 return nil, err |
1040 end | 1040 end |