summaryrefslogtreecommitdiff
path: root/script/meta/bee/socket.lua
blob: 55c349a6c91e500506edb1e570fbabc53571090d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---@meta

---@alias bee.socket.protocol
---| 'tcp'
---| 'udp'
---| 'unix'
---| 'tcp6'
---| 'udp6'

---@class bee.socket
local socket = {}

---@param protocol bee.socket.protocol
---@return bee.socket.fd?
---@return string?
function socket.create(protocol) end

---@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

---@return bee.socket.fd
---@return bee.socket.fd
function socket.pair() 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 lightuserdata
function fd:detach() end

---@return boolean
function fd:status() end

---@return bee.socket.fd
function fd:accept() end

return socket