{
  "classes": [
    {
      "constants": [],
      "types": [
        {
          "lua_type": "type AddrInfo = {\n    family: number,\n    type: number,\n    proto: number,\n    canonname: string,\n    addr: string,\n    port: number,\n}",
          "name": "AddrInfo",
          "tags": [],
          "source": {
            "path": "",
            "line": 242
          },
          "fields": [
            {
              "lua_type": "family: number",
              "name": "family",
              "desc": ""
            },
            {
              "lua_type": "type: number",
              "name": "type",
              "desc": ""
            },
            {
              "lua_type": "proto: number",
              "name": "proto",
              "desc": ""
            },
            {
              "lua_type": "canonname: string",
              "name": "canonname",
              "desc": ""
            },
            {
              "lua_type": "addr: string",
              "name": "addr",
              "desc": ""
            },
            {
              "lua_type": "port: number",
              "name": "port",
              "desc": ""
            }
          ],
          "desc": "Result record from [[getAddrInfo]], representing a single resolved\naddress with its protocol metadata.\n"
        }
      ],
      "name": "@eryx/_socket",
      "tags": [],
      "functions": [
        {
          "source": {
            "path": "",
            "line": 271
          },
          "is_method": false,
          "signature": "_socket.poll(\n    timeout: number?  -- How long to wait for I/O readiness, in seconds. `0` (default) returns immediately if nothing is ready. `-1` blocks until at least one fd is ready.\n) → (\n    number  -- Number of coroutines that were resumed this call. \n)",
          "owner": "_socket",
          "desc": "Drives the async I/O scheduler.\n\nCall this **once per frame**, before [[task.step]], to resume any\ncoroutines that are waiting on socket I/O (recv, send, accept, connect).\n\n```luau\nwhile running do\n\t_socket.poll()\n\ttask.step()\nend\n```\n",
          "tags": [],
          "name": "poll",
          "return_str": "number",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "number",
              "desc": "Number of coroutines that were resumed this call. "
            }
          ],
          "params": [
            {
              "lua_type": "number?",
              "name": "timeout",
              "desc": "How long to wait for I/O readiness, in seconds. `0` (default) returns immediately if nothing is ready. `-1` blocks until at least one fd is ready."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 288
          },
          "is_method": false,
          "signature": "_socket.socket(\n    family: number,  -- Address family - `AF_INET` (IPv4) or `AF_INET6` (IPv6).\n    type: number,  -- Socket type - `SOCK_STREAM` (TCP) or `SOCK_DGRAM` (UDP).\n    proto: number?  -- Protocol number, or `nil` to auto-select (usually 0).\n) → (\n    Socket  -- The newly created socket. \n)",
          "owner": "_socket",
          "desc": "Creates a new socket.\n\n```luau\nlocal tcp = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM)\nlocal udp = _socket.socket(_socket.AF_INET, _socket.SOCK_DGRAM)\n```\n",
          "tags": [],
          "name": "socket",
          "return_str": "Socket",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "Socket",
              "desc": "The newly created socket. "
            }
          ],
          "params": [
            {
              "lua_type": "number",
              "name": "family",
              "desc": "Address family - `AF_INET` (IPv4) or `AF_INET6` (IPv6)."
            },
            {
              "lua_type": "number",
              "name": "type",
              "desc": "Socket type - `SOCK_STREAM` (TCP) or `SOCK_DGRAM` (UDP)."
            },
            {
              "lua_type": "number?",
              "name": "proto",
              "desc": "Protocol number, or `nil` to auto-select (usually 0)."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 311
          },
          "is_method": false,
          "signature": "_socket.getAddrInfo(\n    host: string?,  -- Hostname or numeric address, or `nil` for the wildcard address.\n    service: (string | number)?,  -- Service name (e.g. `\"http\"`) or port number.\n    family: number?,  -- Desired address family, or `AF_UNSPEC` to allow any.\n    type: number?,  -- Desired socket type (e.g. `SOCK_STREAM`), or `nil` for any.\n    proto: number?,  -- Desired protocol, or `nil` for any.\n    flags: number?  -- Bitwise OR of `AI_*` flags (e.g. `AI_PASSIVE`).\n) → (\n    {AddrInfo}  -- An array of resolved address records. \n)",
          "owner": "_socket",
          "desc": "Resolves a host/service pair into a list of address records suitable\nfor creating and connecting sockets.\n\n```luau\nlocal results = _socket.getaddrinfo(\"example.com\", 443, _socket.AF_INET, _socket.SOCK_STREAM)\nfor _, info in results do\n\tprint(info.addr, info.port)\nend\n```\n",
          "tags": [],
          "name": "getAddrInfo",
          "return_str": "{ AddrInfo }",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "{ AddrInfo }",
              "desc": "An array of resolved address records. "
            }
          ],
          "params": [
            {
              "lua_type": "string?",
              "name": "host",
              "desc": "Hostname or numeric address, or `nil` for the wildcard address."
            },
            {
              "lua_type": "(string | number)?",
              "name": "service",
              "desc": "Service name (e.g. `\"http\"`) or port number."
            },
            {
              "lua_type": "number?",
              "name": "family",
              "desc": "Desired address family, or `AF_UNSPEC` to allow any."
            },
            {
              "lua_type": "number?",
              "name": "type",
              "desc": "Desired socket type (e.g. `SOCK_STREAM`), or `nil` for any."
            },
            {
              "lua_type": "number?",
              "name": "proto",
              "desc": "Desired protocol, or `nil` for any."
            },
            {
              "lua_type": "number?",
              "name": "flags",
              "desc": "Bitwise OR of `AI_*` flags (e.g. `AI_PASSIVE`)."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 332
          },
          "is_method": false,
          "signature": "_socket.getNameInfo(\n    host: string,  -- The numeric IP address to look up.\n    port: number,  -- The port number.\n    flags: number?  -- Bitwise OR of `NI_*` flags to control name resolution.\n) → (\n    string,  -- The resolved hostname.\n    string  -- The resolved service name. \n)",
          "owner": "_socket",
          "desc": "Reverse-resolves a numeric address and port into a hostname and\nservice name.\n",
          "tags": [],
          "name": "getNameInfo",
          "return_str": "(string, string)",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "string",
              "desc": "The resolved hostname."
            },
            {
              "lua_type": "string",
              "desc": "The resolved service name. "
            }
          ],
          "params": [
            {
              "lua_type": "string",
              "name": "host",
              "desc": "The numeric IP address to look up."
            },
            {
              "lua_type": "number",
              "name": "port",
              "desc": "The port number."
            },
            {
              "lua_type": "number?",
              "name": "flags",
              "desc": "Bitwise OR of `NI_*` flags to control name resolution."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 337
          },
          "is_method": false,
          "signature": "_socket.htons(x: number) → number",
          "owner": "_socket",
          "desc": "Converts a 16-bit value from host byte order to network byte order.",
          "tags": [],
          "name": "htons",
          "return_str": "number",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "number",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "number",
              "name": "x",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 341
          },
          "is_method": false,
          "signature": "_socket.ntohs(x: number) → number",
          "owner": "_socket",
          "desc": "Converts a 16-bit value from network byte order to host byte order.",
          "tags": [],
          "name": "ntohs",
          "return_str": "number",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "number",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "number",
              "name": "x",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 345
          },
          "is_method": false,
          "signature": "_socket.htonl(x: number) → number",
          "owner": "_socket",
          "desc": "Converts a 32-bit value from host byte order to network byte order.",
          "tags": [],
          "name": "htonl",
          "return_str": "number",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "number",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "number",
              "name": "x",
              "desc": ""
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 349
          },
          "is_method": false,
          "signature": "_socket.ntohl(x: number) → number",
          "owner": "_socket",
          "desc": "Converts a 32-bit value from network byte order to host byte order.",
          "tags": [],
          "name": "ntohl",
          "return_str": "number",
          "function_type": "Function",
          "returns": [
            {
              "lua_type": "number",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "number",
              "name": "x",
              "desc": ""
            }
          ]
        }
      ],
      "properties": [],
      "source": {
        "path": "",
        "line": 0
      },
      "desc": "Low-level BSD socket API for Luau.\n\nThis module exposes the platform's native socket interface, providing\nTCP and UDP networking with non-blocking I/O support. All data transfer\nuses Luau `buffer` objects for zero-copy efficiency.\n\n:::caution\nThis is a **low-level** API. For HTTP, prefer using `@eryx/http`,\n   which handle framing, TLS, and connection management automatically.\n:::\n\n```luau\nlocal sock = _socket.socket(_socket.AF_INET, _socket.SOCK_STREAM)\nsock:connect(\"127.0.0.1\", 8080)\nsock:sendAll(buffer.fromstring(\"GET / HTTP/1.0\\r\\n\\r\\n\"))\nlocal data = sock:recv(4096)\nprint(buffer.tostring(data))\nsock:close()\n```\n"
    },
    {
      "is_primary_export": false,
      "source": {
        "path": "",
        "line": 23
      },
      "tags": [],
      "properties": [
        {
          "tags": [],
          "lua_type": "accept: ((self: Socket) → (Socket, string, number)) | ((self: Socket) → (nil, nil, nil))",
          "name": "accept",
          "desc": "Accepts an incoming connection, returning a new socket for\nthe client along with the remote address and port.\n\n:::caution\nThis call **blocks** the current thread until a connection arrives\n(unless the socket is set to non-blocking mode via\n[[Socket.setblocking]]).\n:::\n\nA nil return value indicates a non-blocking operation that would\nhave blocked.\n"
        },
        {
          "tags": [],
          "lua_type": "recvFrom: ((self: Socket, bufsize: number) → (buffer, string, number)) | ((self: Socket, bufsize: number) → (nil, nil, nil))",
          "name": "recvFrom",
          "desc": "Receives a datagram of up to `bufsize` bytes along with the\nsender's address (UDP).\n\nA nil return value indicates a non-blocking operation that would\nhave blocked.\n"
        }
      ],
      "desc": "",
      "name": "Socket",
      "functions": [
        {
          "source": {
            "path": "",
            "line": 33
          },
          "is_method": true,
          "signature": "Socket:bind(\n    host: string,  -- The local address to bind to.\n    port: number  -- The port number to bind to. \n) → ()",
          "desc": "Binds the socket to a local address and port.\n\nMust be called before [[Socket.listen]] for server sockets. Use host\n`\"0.0.0.0\"` or `\"\"` to bind to all interfaces.\n",
          "tags": [],
          "name": "bind",
          "return_str": "()",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "string",
              "name": "host",
              "desc": "The local address to bind to."
            },
            {
              "lua_type": "number",
              "name": "port",
              "desc": "The port number to bind to. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 44
          },
          "is_method": true,
          "signature": "Socket:listen(\n    backlog: number?  -- Maximum number of queued connections.  Defaults to a system-defined value (usually 128) when omitted. \n) → ()",
          "desc": "Starts listening for incoming connections.\n\nThe socket must have been [[Socket.bind|bound]] first. After calling\nthis, use [[Socket.accept]] to accept individual connections.\n",
          "tags": [],
          "name": "listen",
          "return_str": "()",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "number?",
              "name": "backlog",
              "desc": "Maximum number of queued connections.  Defaults to a system-defined value (usually 128) when omitted. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 75
          },
          "is_method": true,
          "signature": "Socket:connect(\n    host: string,  -- The remote address to connect to.\n    port: number  -- The remote port number. \n) → ()",
          "desc": "Opens a connection to a remote host.\n\nFor TCP sockets this performs the full three-way handshake. In\nnon-blocking mode the call may return before the connection is\nfully established.\n",
          "tags": [],
          "name": "connect",
          "return_str": "()",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "string",
              "name": "host",
              "desc": "The remote address to connect to."
            },
            {
              "lua_type": "number",
              "name": "port",
              "desc": "The remote port number. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 83
          },
          "is_method": true,
          "signature": "Socket:close() → ()",
          "desc": "Closes the socket, releasing all associated OS resources.\n\nAfter closing, no further operations may be performed on this socket.\nIt is safe to call `close` multiple times.\n",
          "tags": [],
          "name": "close",
          "return_str": "()",
          "function_type": "Method",
          "returns": [],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 94
          },
          "is_method": true,
          "signature": "Socket:shutdown(\n    how: number  -- The shutdown mode - one of `SHUT_RD`, `SHUT_WR`, or `SHUT_RDWR`. \n) → ()",
          "desc": "Shuts down one or both halves of the connection without closing the\nsocket descriptor.\n\nUse `SHUT_RD` (0) to stop reads, `SHUT_WR` (1) to stop writes,\nor `SHUT_RDWR` (2) to stop both.\n",
          "tags": [],
          "name": "shutdown",
          "return_str": "()",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "number",
              "name": "how",
              "desc": "The shutdown mode - one of `SHUT_RD`, `SHUT_WR`, or `SHUT_RDWR`. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 109
          },
          "is_method": true,
          "signature": "Socket:send(\n    data: buffer  -- The data to send.\n) → (\n    number  -- Number of bytes sent. \n)",
          "desc": "Sends data over the socket. Returns the number of bytes actually\nsent, which may be less than the full buffer length.\n\nFor guaranteed delivery of the entire buffer, use [[Socket.sendall]]\ninstead.\n\nA nil return value indicates a non-blocking operation that would\nhave blocked.\n",
          "tags": [],
          "name": "send",
          "return_str": "number?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "number?",
              "desc": "Number of bytes sent. "
            }
          ],
          "params": [
            {
              "lua_type": "buffer",
              "name": "data",
              "desc": "The data to send."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 122
          },
          "is_method": true,
          "signature": "Socket:sendAll(\n    data: buffer  -- The data to send. \n) → boolean",
          "desc": "Sends all data in the buffer, retrying internally until every byte\nhas been transmitted or an error occurs.\n\nIn blocking operation, this function always returns `true`.\n\nIn non-blocking operation, this function returns `false` is the\noperation would have blocked.\n",
          "tags": [],
          "name": "sendAll",
          "return_str": "boolean",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "boolean",
              "desc": ""
            }
          ],
          "params": [
            {
              "lua_type": "buffer",
              "name": "data",
              "desc": "The data to send. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 138
          },
          "is_method": true,
          "signature": "Socket:sendTo(\n    data: buffer,  -- The datagram payload to send.\n    host: string,  -- The destination address.\n    port: number  -- The destination port.\n) → (\n    number  -- Number of bytes sent. \n)",
          "desc": "Sends data to a specific destination address (UDP).\n\nPrimarily used with `SOCK_DGRAM` sockets. Returns the number of\nbytes actually sent.\n\nA nil return value indicates a non-blocking operation that would\nhave blocked.\n",
          "tags": [],
          "name": "sendTo",
          "return_str": "number?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "number?",
              "desc": "Number of bytes sent. "
            }
          ],
          "params": [
            {
              "lua_type": "buffer",
              "name": "data",
              "desc": "The datagram payload to send."
            },
            {
              "lua_type": "string",
              "name": "host",
              "desc": "The destination address."
            },
            {
              "lua_type": "number",
              "name": "port",
              "desc": "The destination port."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 153
          },
          "is_method": true,
          "signature": "Socket:recv(\n    bufsize: number  -- Maximum number of bytes to receive.\n) → (\n    buffer  -- The received data. \n)",
          "desc": "Receives up to `bufsize` bytes from the socket.\n\nReturns a buffer containing the received data, which may be shorter\nthan `bufsize`. An empty buffer (length 0) typically indicates the\nremote end has closed the connection.\n\nA nil return value indicates a non-blocking operation that would\nhave blocked.\n",
          "tags": [],
          "name": "recv",
          "return_str": "buffer?",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "buffer?",
              "desc": "The received data. "
            }
          ],
          "params": [
            {
              "lua_type": "number",
              "name": "bufsize",
              "desc": "Maximum number of bytes to receive."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 182
          },
          "is_method": true,
          "signature": "Socket:setSockOpt(\n    level: number,  -- The protocol level (e.g. `SOL_SOCKET`, `IPPROTO_TCP`).\n    optname: number,  -- The option identifier.\n    value: number | boolean  -- The value to set - a number or boolean depending on the option. \n) → ()",
          "desc": "Sets a socket option.\n\nCommon combinations:\n- `SOL_SOCKET, SO_REUSEADDR, true` - allow port reuse\n- `SOL_SOCKET, SO_KEEPALIVE, true` - enable keep-alive\n- `IPPROTO_TCP, TCP_NODELAY, true` - disable Nagle's algorithm\n",
          "tags": [],
          "name": "setSockOpt",
          "return_str": "()",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "number",
              "name": "level",
              "desc": "The protocol level (e.g. `SOL_SOCKET`, `IPPROTO_TCP`)."
            },
            {
              "lua_type": "number",
              "name": "optname",
              "desc": "The option identifier."
            },
            {
              "lua_type": "number | boolean",
              "name": "value",
              "desc": "The value to set - a number or boolean depending on the option. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 191
          },
          "is_method": true,
          "signature": "Socket:getSockOpt(\n    level: number,  -- The protocol level (e.g. `SOL_SOCKET`, `IPPROTO_TCP`).\n    optname: number  -- The option identifier.\n) → (\n    number  -- The current option value. \n)",
          "desc": "Gets the current value of a socket option.\n",
          "tags": [],
          "name": "getSockOpt",
          "return_str": "number",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "number",
              "desc": "The current option value. "
            }
          ],
          "params": [
            {
              "lua_type": "number",
              "name": "level",
              "desc": "The protocol level (e.g. `SOL_SOCKET`, `IPPROTO_TCP`)."
            },
            {
              "lua_type": "number",
              "name": "optname",
              "desc": "The option identifier."
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 202
          },
          "is_method": true,
          "signature": "Socket:setBlocking(\n    flag: boolean  -- `true` for blocking, `false` for non-blocking. \n) → ()",
          "desc": "Switches the socket between blocking and non-blocking mode.\n\nIn non-blocking mode, operations like [[Socket.recv]] and\n[[Socket.send]] will raise an error instead of waiting when no\ndata is available.\n",
          "tags": [],
          "name": "setBlocking",
          "return_str": "()",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "boolean",
              "name": "flag",
              "desc": "`true` for blocking, `false` for non-blocking. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 211
          },
          "is_method": true,
          "signature": "Socket:setTimeout(\n    seconds: number?  -- Timeout duration, or `nil` for no timeout. \n) → ()",
          "desc": "Sets a timeout (in seconds) for blocking socket operations.\n\nPass `nil` or `0` to disable the timeout (wait indefinitely).\n",
          "tags": [],
          "name": "setTimeout",
          "return_str": "()",
          "function_type": "Method",
          "returns": [],
          "params": [
            {
              "lua_type": "number?",
              "name": "seconds",
              "desc": "Timeout duration, or `nil` for no timeout. "
            }
          ]
        },
        {
          "source": {
            "path": "",
            "line": 219
          },
          "is_method": true,
          "signature": "Socket:getPeerName() → (\n    string,  -- The remote IP address.\n    number  -- The remote port. \n)",
          "desc": "Returns the remote address and port of the connected peer.\n",
          "tags": [],
          "name": "getPeerName",
          "return_str": "(string, number)",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": "The remote IP address."
            },
            {
              "lua_type": "number",
              "desc": "The remote port. "
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 227
          },
          "is_method": true,
          "signature": "Socket:getSockName() → (\n    string,  -- The local IP address.\n    number  -- The local port. \n)",
          "desc": "Returns the local address and port the socket is bound to.\n",
          "tags": [],
          "name": "getSockName",
          "return_str": "(string, number)",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "string",
              "desc": "The local IP address."
            },
            {
              "lua_type": "number",
              "desc": "The local port. "
            }
          ],
          "params": []
        },
        {
          "source": {
            "path": "",
            "line": 235
          },
          "is_method": true,
          "signature": "Socket:fileNo() → (\n    number  -- The file descriptor. \n)",
          "desc": "Returns the underlying OS file descriptor / handle number for\nthis socket. Useful for advanced I/O multiplexing.\n",
          "tags": [],
          "name": "fileNo",
          "return_str": "number",
          "function_type": "Method",
          "returns": [
            {
              "lua_type": "number",
              "desc": "The file descriptor. "
            }
          ],
          "params": []
        }
      ],
      "metamethods": [],
      "types": []
    }
  ]
}