diff options
| author | ruki <[email protected]> | 2019-10-27 14:41:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-10-27 14:41:13 +0800 |
| commit | 6df3d8bf595b3645022b4d465fd1192f9033913e (patch) | |
| tree | 7f18711b1e4a9a88e1dfaa5840db71869b1e045c /xmake/core/base/socket.lua | |
| parent | 74fe92ec5fab1725b139567f468f49cab4580888 (diff) | |
add socket.recv
Diffstat (limited to 'xmake/core/base/socket.lua')
| -rw-r--r-- | xmake/core/base/socket.lua | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/xmake/core/base/socket.lua b/xmake/core/base/socket.lua index e85ec0301..b2be9bc28 100644 --- a/xmake/core/base/socket.lua +++ b/xmake/core/base/socket.lua @@ -160,14 +160,13 @@ function _instance:send(data, start, last) end -- send it - local result, errors = io.socket_send(self._SOCK, data, start, last) - if result < 0 and errors then + local real, errors = io.socket_send(self._SOCK, data, start, last) + if real < 0 and errors then errors = string.format("%s: %s", self, errors) end - return result, errors + return real, errors end --- TODO -- recv data from socket function _instance:recv(size) @@ -178,11 +177,11 @@ function _instance:recv(size) end -- recv it - local result, errors = io.socket_recv(self._SOCK, data, size) - if not result and errors then - errors = string.format("%s: %s", self, errors) + local real, data_or_errors = io.socket_recv(self._SOCK, size) + if real < 0 and data_or_errors then + data_or_errors = string.format("%s: %s", self, data_or_errors) end - return result, errors + return real, data_or_errors end -- wait socket events |
