-
Notifications
You must be signed in to change notification settings - Fork 6
/
luasocket_doc.lua
165 lines (122 loc) · 3.81 KB
/
luasocket_doc.lua
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---@meta
---@class LTN12.Sink
---@class LTN12.Source
---@class LuaSocket
---@field headers.canonic table
---@field _DATAGRAMSIZE number
---@field _SETSIZE number
---@field _SOCKETINVALID number
---@field _VERSION string
---@field _DEBUG boolean
local socket={}
---@return LuaSocket.server
---@param address string
---@param port string
---@param backlog? number
function socket.bind(address,port,backlog) end
---@param address string
---@param port number
---@param locaddr? string
---@param locport? number
---@param family? 'inet' | 'inet6'
---@return LuaSocket.client
function socket.connect(address,port,locaddr,locport,family) end
socket.connect4=socket.connect
socket.connect6=socket.connect
---@param recvt LuaSocket.master[]
---@param sendt LuaSocket.master[]
---@param timeout? number?
function socket.select(recvt,sendt,timeout) end
---Throw an exception, like assert
function socket.try(ret1,ret2,...) end
---Patch a function to be the finalizer of a SAFE function, if the SAFE function crashed, the finalizer function will be called
---@param finalizer function
function socket.newtry(finalizer) end
---Create a SAFE function which calling it is silimar to pcall the original function, but can only handle try/assert/error
---@param func function
function socket.protect(func) end
---Return retD+1, retD+2, ...
---@param D number
---@param ret1 any
---@param ret2 any
---@param ... any
function socket.skip(D,ret1,ret2,...) end
---LTN12
---@param mode string
---@param sock LuaSocket.master
---@return LTN12.Sink
function socket.sink(mode,sock) end
---@param mode string
---@param sock LuaSocket.master
---@param length? number
---@return LTN12.Source
function socket.source(mode,sock,length) end
---Just sleep
---@param time number
function socket.sleep(time) end
---Just getTime
---@return number ms
function socket.gettime() end
---@class LuaSocket.master
local master={}
---@param address string
---@param port string
---@return number? success, string errInfo
function master:bind(address,port) end
---@param address string
---@param port string
---@return number? success, string errInfo
function master:connect(address,port) end
function master:close() end
---@return boolean hasData
function master:dirty() end
---@return string
function master:getsockname() end
---@return number bytesRecv, number bytesSent, number secLifetime
function master:getstats() end
---@return number
function master:gettimeout() end
---Wait for a connection, then transform into a server object
---@param backlog number
function master:listen(backlog) end
---For throttling of bandwidth
---@param received number bytes
---@param sent number bytes
---@param age number seconds
function master:setstats(received,sent,age) end
---@param value? number nil or negative means block
---@param mode? 'b' | 't'
function master:settimeout(value,mode) end
---@return string
function master:getfd() end
---@param fd string
function master:setfd(fd) end
---@class LuaSocket.server: LuaSocket.master
local server={}
---@return LuaSocket.client
function server:accept() end
---@param option string
function server:getoption(option) end
---@param option string
---@param value? any
function server:setoption(option,value) end
---@class LuaSocket.client: LuaSocket.master
local client={}
---@param option string
function client:getoption(option) end
---@param option string
---@param value? any
function client:setoption(option,value) end
---@return string
function client:getpeername() end
---@param pattern? '*l' | '*a' | number
---@param prefix? string
function client:receive(pattern,prefix) end
---Send data string between i and j (byte) if given
---@param data string
---@param i? number
---@param j? number
function client:send(data,i,j) end
---Close one side of a full-duplex connection
---@param mode? 'both' | 'send' | 'receive'
function client:shutdown(mode) end