Facebook Engineer?

This function is available as TCP\gen_connect_nd() in Facebook's www repository.

Connect to a socket asynchronously, returning a non-disposable handle

namespace HH\Lib\TCP;

function connect_nd_async(
  string $host,
  int $port,
  ConnectOptions $opts = array (
): Awaitable<CloseableSocket>;

If using IPv6 with a fallback to IPv4 with a connection timeout, the timeout will apply separately to the IPv4 and IPv6 connection attempts.


  • string $host
  • int $port
  • ConnectOptions $opts = array ( )