From ddaf74b1fab93b16ff4f875e4bf648c503e022a8 Mon Sep 17 00:00:00 2001 From: sofa Date: Tue, 31 Dec 2024 15:21:42 +1300 Subject: [PATCH 1/2] Fix params and return of socket.bind --- library/socket.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/socket.lua b/library/socket.lua index 8f8ce92..03b4376 100644 --- a/library/socket.lua +++ b/library/socket.lua @@ -48,7 +48,8 @@ socket.headers.canonic = {} --- ---@param address string ---@param port integer ----@param backlog? any +---@param backlog? integer +---@return TCPSocket --- ---😱 [Types](https://github.com/LuaCATS/luasocket/blob/main/library/socket.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/luasocket/pulls) function socket.bind(address, port, backlog) end From ff4509c230bd74eefa480e7d281ad88815ca40ff Mon Sep 17 00:00:00 2001 From: sofa Date: Tue, 31 Dec 2024 15:26:20 +1300 Subject: [PATCH 2/2] Fix documentation of socket.connect4 and connect6 These functions don't have a family argument --- library/socket.lua | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/library/socket.lua b/library/socket.lua index 03b4376..64f4b63 100644 --- a/library/socket.lua +++ b/library/socket.lua @@ -76,46 +76,32 @@ function socket.bind(address, port, backlog) end function socket.connect(address, port, locaddr, locport, family) end --- ----This function is a shortcut that creates and returns a TCP client object ----connected to a remote `address` at a given `port`. Optionally, +---This function is a shortcut that creates and returns an IPv4 TCP client +---object connected to a remote `address` at a given `port`. Optionally, ---the user can also specify the local address and port to bind ----(`locaddr` and `locport`), or restrict the socket family ----to "`inet`" or "`inet6`". ---- ----Without specifying `family` to `connect`, whether a tcp or tcp6 ----connection is created depends on your system configuration. Two variations ----of connect are defined as simple helper functions that restrict the ----`family`, `socket.connect4` and `socket.connect6`. +---(`locaddr` and `locport`) --- ---@param address string ---@param port integer ---@param locaddr? string ---@param locport? integer ----@param family? 'inet'|'inet6' --- ---😱 [Types](https://github.com/LuaCATS/luasocket/blob/main/library/socket.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/luasocket/pulls) -function socket.connect4(address, port, locaddr, locport, family) end +function socket.connect4(address, port, locaddr, locport) end --- ----This function is a shortcut that creates and returns a TCP client object ----connected to a remote `address` at a given `port`. Optionally, +---This function is a shortcut that creates and returns an IPv6 TCP client +---object connected to a remote `address` at a given `port`. Optionally, ---the user can also specify the local address and port to bind ----(`locaddr` and `locport`), or restrict the socket family ----to "`inet`" or "`inet6`". ---- ----Without specifying `family` to `connect`, whether a tcp or tcp6 ----connection is created depends on your system configuration. Two variations ----of connect are defined as simple helper functions that restrict the ----`family`, `socket.connect4` and `socket.connect6`. +---(`locaddr` and `locport`) --- ---@param address string ---@param port integer ---@param locaddr? string ---@param locport? integer ----@param family? 'inet'|'inet6' --- ---😱 [Types](https://github.com/LuaCATS/luasocket/blob/main/library/socket.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/luasocket/pulls) -function socket.connect6(address, port, locaddr, locport, family) end +function socket.connect6(address, port, locaddr, locport) end --- ---This constant is set to `true` if the library was compiled