diff options
Diffstat (limited to 'script/meta/bee/socket.lua')
-rw-r--r-- | script/meta/bee/socket.lua | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/script/meta/bee/socket.lua b/script/meta/bee/socket.lua new file mode 100644 index 00000000..b77c498b --- /dev/null +++ b/script/meta/bee/socket.lua @@ -0,0 +1,62 @@ +---@meta + +---@alias bee.socket.protocol +---| 'tcp' +---| 'udp' +---| 'unix' +---| 'tcp6' +---| 'udp6' + +---@class bee.socket +---@overload fun(protocol: bee.socket.protocol): bee.socket.fd?, string? +local socket = {} + +---@param readfds? bee.socket.fd[] +---@param writefds? bee.socket.fd[] +---@param timeout number +---@return bee.socket.fd[] # readfds +---@return bee.socket.fd[] # writefds +function socket.select(readfds, writefds, timeout) end + +---@param handle lightuserdata +---@return bee.socket.fd +function socket.fd(handle) end + +---@class bee.socket.fd +local fd = {} + +---@param addr string +---@param port? integer +---@return boolean +---@return string? +function fd:bind(addr, port) end + +function fd:close() end + +---@return boolean +---@return string? +function fd:listen() end + +---@param addr string +---@param port integer +---@return boolean +---@return string? +function fd:connect(addr, port) end + +---@param len? integer +---@return string | false +function fd:recv(len) end + +---@param content string +function fd:send(content) end + +---@return lightuserdata +function fd:handle() end + +---@return boolean +function fd:status() end + +---@return bee.socket.fd +function fd:accept() end + +return socket |