tcp

class uv.tcp()

Construct a new Tcp object, inheriting from the Stream object.

Note

Stream object methods apply here.

uv.tcp.open(fd)

Open an existing file descriptor/SOCKET as a TCP handle.

Arguments:
  • fd (number) – existing file descriptor or socket.
Throws:

If unable to open

uv.tcp.nodelay(enable)

Enable TCP_NODELAY, which disables Nagle’s algorithm.

Arguments:
  • enable (bool) – enable or disable nodelay
Throws:

If unable to set nodelay

uv.tcp.simultaneous_accepts(enable)

Enable / disable simultaneous asynchronous accept requests

Arguments:
  • enable (bool) – enable or disable simultaneous accepts for object.
Throws:

If unable to set simultaneous_accepts

uv.tcp.keepalive(enable, delay)

Enable / disable TCP keepalive.

Arguments:
  • enable (bool) – enable or disable keepalive
  • delay (int) – initial delay for keepalive in seconds.
Throws:

If unable to set keepalive

uv.tcp.bind(host, port)

Bind to a specified host/port.

Arguments:
  • host (string) – IP address to bind to.
  • port (int) – Port to bind to.
Throws:

If unable to bind to host/port

uv.tcp.getpeername()

Get the address of the client/peer connected to the handle.

Returns:An object containing the family, port, and IP of the peer.
Throws:If unable to get peername
uv.tcp.getsockname()

Get the address of the socket (us)

Returns:An object containing the family, port, and IP of the socket.
Throws:If unable to get socket name.
uv.tcp.connect(host, port)

Connect a socket to a host, and port.

Arguments:
  • host (string) – IP address to connect to.
  • port (int) – Port to connect to.
Throws:

If unable to connect to host/port.