Skip to content

Commit 41e635b

Browse files
authored
Merge branch 'actboy168:master' into master
2 parents 62dfcb0 + 758d789 commit 41e635b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

extension/script/common/net.lua

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
local platform = require "bee.platform"
12
local socket = require "bee.socket"
23
local epoll = require "bee.epoll"
34
local fs = require "bee.filesystem"
@@ -66,7 +67,7 @@ function stream:write(data)
6667
if self._writebuf == "" then
6768
fd_set_write(self)
6869
end
69-
self._writebuf = self._writebuf .. data
70+
self._writebuf = self._writebuf..data
7071
end
7172

7273
function stream:is_closed()
@@ -151,7 +152,7 @@ function connect:write(data)
151152
if data == "" then
152153
return
153154
end
154-
self._writebuf = self._writebuf .. data
155+
self._writebuf = self._writebuf..data
155156
end
156157

157158
function connect:is_closed()
@@ -176,15 +177,15 @@ function m.listen(protocol, address, port)
176177
fs.remove(address)
177178
end
178179
end
179-
do
180+
if platform.os ~= "windows" then
180181
-- set SO_REUSEADDR so we can bind again to the same address
181182
-- after a quick restart:
182-
local ok, err = fd:option("reuseaddr", 1)
183-
if not ok then
184-
fd:close()
185-
return nil, err
186-
end
187-
end
183+
local ok, err = fd:option("reuseaddr", 1)
184+
if not ok then
185+
fd:close()
186+
return nil, err
187+
end
188+
end
188189
do
189190
local ok, err = fd:bind(address, port)
190191
if not ok then
@@ -206,7 +207,7 @@ function m.listen(protocol, address, port)
206207
shutdown_r = false,
207208
shutdown_w = true,
208209
}
209-
epfd:event_add(fd, EPOLLIN, function()
210+
epfd:event_add(fd, EPOLLIN, function ()
210211
local new_fd, err = fd:accept()
211212
if new_fd == nil then
212213
s:close()
@@ -223,7 +224,7 @@ function m.listen(protocol, address, port)
223224
shutdown_w = false,
224225
}, stream_mt)
225226
if on_event(s, "accepted", new_s) then
226-
epfd:event_add(new_fd, new_s._flags, function(event)
227+
epfd:event_add(new_fd, new_s._flags, function (event)
227228
update_stream(new_s, event)
228229
end)
229230
else
@@ -257,7 +258,7 @@ function m.connect(protocol, address, port)
257258
shutdown_r = false,
258259
shutdown_w = false,
259260
}
260-
epfd:event_add(fd, EPOLLOUT, function()
261+
epfd:event_add(fd, EPOLLOUT, function ()
261262
local ok, err = fd:status()
262263
if ok then
263264
on_event(s, "connected")
@@ -272,7 +273,7 @@ function m.connect(protocol, address, port)
272273
else
273274
s._flags = EPOLLIN
274275
end
275-
epfd:event_mod(s._fd, s._flags, function(event)
276+
epfd:event_mod(s._fd, s._flags, function (event)
276277
update_stream(s, event)
277278
end)
278279
else
@@ -307,4 +308,3 @@ function m.update(timeout)
307308
end
308309

309310
return m
310-

0 commit comments

Comments
 (0)