diff options
| author | ruki <[email protected]> | 2019-10-13 00:03:03 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-10-13 00:03:03 +0800 |
| commit | 9d3eab796916f907a5fc95b4333791ee2ac6df49 (patch) | |
| tree | 7e8ff814b05139c11ef3cf3276f0b0f43fbd4f66 /xmake/core/base | |
| parent | 18468a7582fa6b277380a752ff3b7a2a37bc77bd (diff) | |
implement to open socket
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/io/socket.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/xmake/core/base/io/socket.lua b/xmake/core/base/io/socket.lua index 9f26d82ed..53eb934bd 100644 --- a/xmake/core/base/io/socket.lua +++ b/xmake/core/base/io/socket.lua @@ -84,11 +84,17 @@ function _socket:__gc() end -- open a socket +-- +-- @param socktype the socket type, e.g. tcp, udp, icmp +-- @param family the address family, e.g. ipv4, ipv6 +-- +-- @return the socket instance +-- function io.opensock(socktype, family) - local sock = io.socket_open(socktype, family) + local sock, errors = io.socket_open(socktype, family) if sock then return _socket.new(socktype, family, sock) else - return nil, string.format("failed to open socket!") + return nil, errors or string.format("failed to open socket(%s/%s)!", socktype, family) end end |
