Skip to content

Commit

Permalink
perf(socket): simplify error message returned
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  • Loading branch information
zhaojh329 committed Sep 16, 2023
1 parent 1e82ef6 commit f649c30
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions socket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ local dgram_methods = {
local function create_socket(family, typ, protocol, methods, name)
local fd, err = socket.socket(family, typ, protocol)
if not fd then
return nil, 'create socket: ' .. sys.strerror(err)
return nil, sys.strerror(err)
end

return sock_setmetatable(fd, family, typ, methods, name)
Expand Down Expand Up @@ -505,12 +505,12 @@ function M.listen_unix(path, options)

local ok, err = sock:bind(path)
if not ok then
return nil, 'bind: ' .. err
return nil, err
end

ok, err = sock:listen(options.backlog)
if not ok then
return nil, 'listen: ' .. err
return nil, err
end

return sock
Expand Down Expand Up @@ -538,12 +538,12 @@ local function listen_tcp_common(create, ipaddr, port, options)

local ok, err = sock:bind(ipaddr, port)
if not ok then
return nil, 'bind: ' .. err
return nil, err
end

ok, err = sock:listen(options.backlog)
if not ok then
return nil, 'listen: ' .. err
return nil, err
end

return sock
Expand All @@ -568,13 +568,13 @@ function M.connect_unix(server_path, local_path)
if local_path then
ok, err = sock:bind(local_path)
if not ok then
return nil, 'bind: ' .. err
return nil, err
end
end

ok, err = sock:connect(server_path)
if not ok then
return nil, 'connect: ' .. err
return nil, err
end

return sock
Expand All @@ -588,7 +588,7 @@ local function connect_tcp_common(create, ipaddr, port)

local ok, err = sock:connect(ipaddr, port)
if not ok then
return nil, 'connect: ' .. err
return nil, err
end

return sock
Expand Down

0 comments on commit f649c30

Please sign in to comment.