Software / code / prosody
Comparison
net/server_event.lua @ 5967:3b7206981317
net.server_{select,event}: addclient: Handle missing getaddrinfo
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 23 Dec 2013 23:23:59 +0100 |
| parent | 5966:958ad646c0f2 |
| child | 6055:596539a30e9b |
comparison
equal
deleted
inserted
replaced
| 5966:958ad646c0f2 | 5967:3b7206981317 |
|---|---|
| 740 function addclient( addr, serverport, listener, pattern, sslctx, typ ) | 740 function addclient( addr, serverport, listener, pattern, sslctx, typ ) |
| 741 if sslctx and not has_luasec then | 741 if sslctx and not has_luasec then |
| 742 debug "need luasec, but not available" | 742 debug "need luasec, but not available" |
| 743 return nil, "luasec not found" | 743 return nil, "luasec not found" |
| 744 end | 744 end |
| 745 if not typ then | 745 if getaddrinfo and not typ then |
| 746 local addrinfo, err = getaddrinfo(addr) | 746 local addrinfo, err = getaddrinfo(addr) |
| 747 if not addrinfo then return nil, err end | 747 if not addrinfo then return nil, err end |
| 748 if addrinfo[1] and addrinfo[1].family == "inet6" then | 748 if addrinfo[1] and addrinfo[1].family == "inet6" then |
| 749 typ = "tcp6" | 749 typ = "tcp6" |
| 750 else | 750 end |
| 751 typ = "tcp" | 751 end |
| 752 end | 752 local create = socket[typ or "tcp"] |
| 753 end | |
| 754 local create = socket[typ] | |
| 755 if type( create ) ~= "function" then | 753 if type( create ) ~= "function" then |
| 756 return nil, "invalid socket type" | 754 return nil, "invalid socket type" |
| 757 end | 755 end |
| 758 local client, err = create() -- creating new socket | 756 local client, err = create() -- creating new socket |
| 759 if not client then | 757 if not client then |