diff options
| author | ruki <[email protected]> | 2019-10-14 22:33:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-10-14 09:22:22 +0800 |
| commit | 91bad8e2dbbe495f93cc14b56742d1af55c6d51b (patch) | |
| tree | 0d79e3110ec26c26dc0729c524b097ef5476275d /xmake/core/base/socket.lua | |
| parent | 5166d62948768bf3bac371816eb113f4cd490965 (diff) | |
improve socket apis
Diffstat (limited to 'xmake/core/base/socket.lua')
| -rw-r--r-- | xmake/core/base/socket.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/xmake/core/base/socket.lua b/xmake/core/base/socket.lua index c5de342c0..ddd89c004 100644 --- a/xmake/core/base/socket.lua +++ b/xmake/core/base/socket.lua @@ -96,6 +96,23 @@ function _instance:bind(addr, port) return result, errors end +-- listen socket +function _instance:listen(backlog) + + -- ensure opened + local ok, errors = self:_ensure_opened() + if not ok then + return -1, errors + end + + -- listen it + local result, errors = io.socket_listen(self._SOCK, backlog or 10) + if not result and errors then + errors = string.format("%s: %s", self, errors) + end + return result, errors +end + -- connect socket function _instance:connect(addr, port) |
