Module socket

This module provides TCP and UDP sockets as well as HTTP, FTP protocol stacks and more.


Refer to the official online documentation: LuaSocket Reference.
Only modified API appears on this page.

Type socket

socket.bind(host, port, backlog_or_hook)

This function is a shortcut that creates and returns a TCP server object bound to a local address and port, ready to accept client connections.

Type socket

Field(s)

socket.bind(host, port, backlog_or_hook)

This function is a shortcut that creates and returns a TCP server object bound to a local address and port, ready to accept client connections.

Modified from the original Luasocket function to support an optional hook argument.

Parameters

  • host : local address to bind to

  • port : local port to bind

  • backlogorhook : Optionally, user can also specify the backlog argument to the listen method (defaults to 32). This third parameter can also be the hook if no backlog parameter is given. -@param hook is an additional parameter (not compatible with luasocket original socket.bind()

Return value

TCP server object

Usages:

  • socket.bind("someaddress", 4242, function hook(...) end)
  • socket.bind("someaddress", 4242, 32,function hook(...) end)