<?php

const AF_UNIX = 1;

const AF_INET = 2;

const AF_INET6 = 10;

const SOCK_STREAM = 1;

const SOCK_DGRAM = 2;

const SOCK_RAW = 3;

const SOCK_SEQPACKET = 5;

const SOCK_RDM = 4;

const MSG_OOB = 1;

const MSG_WAITALL = 256;

const MSG_CTRUNC = 8;

const MSG_TRUNC = 32;

const MSG_PEEK = 2;

const MSG_DONTROUTE = 4;

const MSG_EOR = 128;

const MSG_EOF = 512;

const MSG_CONFIRM = 2048;

const MSG_ERRQUEUE = 8192;

const MSG_NOSIGNAL = 16384;

const MSG_DONTWAIT = 64;

const MSG_MORE = 32768;

const MSG_WAITFORONE = 65536;

const MSG_CMSG_CLOEXEC = 1073741824;

const SO_DEBUG = 1;

const SO_REUSEADDR = 2;

const SO_REUSEPORT = 15;

const SO_KEEPALIVE = 9;

const SO_DONTROUTE = 5;

const SO_LINGER = 13;

const SO_BROADCAST = 6;

const SO_OOBINLINE = 10;

const SO_SNDBUF = 7;

const SO_RCVBUF = 8;

const SO_SNDLOWAT = 19;

const SO_RCVLOWAT = 18;

const SO_SNDTIMEO = 21;

const SO_RCVTIMEO = 20;

const SO_TYPE = 3;

const SO_ERROR = 4;

const SO_BINDTODEVICE = 25;

const SO_ATTACH_REUSEPORT_CBPF = 51;

const SO_DETACH_FILTER = 27;

const SO_DETACH_BPF = 27;

const SOL_SOCKET = 1;

const SOL_UDPLITE = 136;

const SOMAXCONN = 128;

const SO_MARK = 36;

const TCP_NODELAY = 1;

const PHP_NORMAL_READ = 1;

const PHP_BINARY_READ = 2;

const MCAST_JOIN_GROUP = 42;

const MCAST_LEAVE_GROUP = 45;

const MCAST_BLOCK_SOURCE = 43;

const MCAST_UNBLOCK_SOURCE = 44;

const MCAST_JOIN_SOURCE_GROUP = 46;

const MCAST_LEAVE_SOURCE_GROUP = 47;

const IP_MULTICAST_IF = 32;

const IP_MULTICAST_TTL = 33;

const IP_MULTICAST_LOOP = 34;

const IPV6_MULTICAST_IF = 17;

const IPV6_MULTICAST_HOPS = 18;

const IPV6_MULTICAST_LOOP = 19;

const IPV6_V6ONLY = 26;

const IP_BIND_ADDRESS_NO_PORT = 24;

const IP_MTU_DISCOVER = 10;

const IP_PMTUDISC_DO = 2;

const IP_PMTUDISC_DONT = 0;

const IP_PMTUDISC_WANT = 1;

const IP_PMTUDISC_PROBE = 3;

const IP_PMTUDISC_INTERFACE = 4;

const IP_PMTUDISC_OMIT = 5;

const SOCKET_EPERM = 1;

const SOCKET_ENOENT = 2;

const SOCKET_EINTR = 4;

const SOCKET_EIO = 5;

const SOCKET_ENXIO = 6;

const SOCKET_E2BIG = 7;

const SOCKET_EBADF = 9;

const SOCKET_EAGAIN = 11;

const SOCKET_ENOMEM = 12;

const SOCKET_EACCES = 13;

const SOCKET_EFAULT = 14;

const SOCKET_ENOTBLK = 15;

const SOCKET_EBUSY = 16;

const SOCKET_EEXIST = 17;

const SOCKET_EXDEV = 18;

const SOCKET_ENODEV = 19;

const SOCKET_ENOTDIR = 20;

const SOCKET_EISDIR = 21;

const SOCKET_EINVAL = 22;

const SOCKET_ENFILE = 23;

const SOCKET_EMFILE = 24;

const SOCKET_ENOTTY = 25;

const SOCKET_ENOSPC = 28;

const SOCKET_ESPIPE = 29;

const SOCKET_EROFS = 30;

const SOCKET_EMLINK = 31;

const SOCKET_EPIPE = 32;

const SOCKET_ENAMETOOLONG = 36;

const SOCKET_ENOLCK = 37;

const SOCKET_ENOSYS = 38;

const SOCKET_ENOTEMPTY = 39;

const SOCKET_ELOOP = 40;

const SOCKET_EWOULDBLOCK = 11;

const SOCKET_ENOMSG = 42;

const SOCKET_EIDRM = 43;

const SOCKET_ECHRNG = 44;

const SOCKET_EL2NSYNC = 45;

const SOCKET_EL3HLT = 46;

const SOCKET_EL3RST = 47;

const SOCKET_ELNRNG = 48;

const SOCKET_EUNATCH = 49;

const SOCKET_ENOCSI = 50;

const SOCKET_EL2HLT = 51;

const SOCKET_EBADE = 52;

const SOCKET_EBADR = 53;

const SOCKET_EXFULL = 54;

const SOCKET_ENOANO = 55;

const SOCKET_EBADRQC = 56;

const SOCKET_EBADSLT = 57;

const SOCKET_ENOSTR = 60;

const SOCKET_ENODATA = 61;

const SOCKET_ETIME = 62;

const SOCKET_ENOSR = 63;

const SOCKET_ENONET = 64;

const SOCKET_EREMOTE = 66;

const SOCKET_ENOLINK = 67;

const SOCKET_EADV = 68;

const SOCKET_ESRMNT = 69;

const SOCKET_ECOMM = 70;

const SOCKET_EPROTO = 71;

const SOCKET_EMULTIHOP = 72;

const SOCKET_EBADMSG = 74;

const SOCKET_ENOTUNIQ = 76;

const SOCKET_EBADFD = 77;

const SOCKET_EREMCHG = 78;

const SOCKET_ERESTART = 85;

const SOCKET_ESTRPIPE = 86;

const SOCKET_EUSERS = 87;

const SOCKET_ENOTSOCK = 88;

const SOCKET_EDESTADDRREQ = 89;

const SOCKET_EMSGSIZE = 90;

const SOCKET_EPROTOTYPE = 91;

const SOCKET_ENOPROTOOPT = 92;

const SOCKET_EPROTONOSUPPORT = 93;

const SOCKET_ESOCKTNOSUPPORT = 94;

const SOCKET_EOPNOTSUPP = 95;

const SOCKET_EPFNOSUPPORT = 96;

const SOCKET_EAFNOSUPPORT = 97;

const SOCKET_EADDRINUSE = 98;

const SOCKET_EADDRNOTAVAIL = 99;

const SOCKET_ENETDOWN = 100;

const SOCKET_ENETUNREACH = 101;

const SOCKET_ENETRESET = 102;

const SOCKET_ECONNABORTED = 103;

const SOCKET_ECONNRESET = 104;

const SOCKET_ENOBUFS = 105;

const SOCKET_EISCONN = 106;

const SOCKET_ENOTCONN = 107;

const SOCKET_ESHUTDOWN = 108;

const SOCKET_ETOOMANYREFS = 109;

const SOCKET_ETIMEDOUT = 110;

const SOCKET_ECONNREFUSED = 111;

const SOCKET_EHOSTDOWN = 112;

const SOCKET_EHOSTUNREACH = 113;

const SOCKET_EALREADY = 114;

const SOCKET_EINPROGRESS = 115;

const SOCKET_EISNAM = 120;

const SOCKET_EREMOTEIO = 121;

const SOCKET_EDQUOT = 122;

const SOCKET_ENOMEDIUM = 123;

const SOCKET_EMEDIUMTYPE = 124;

const IPPROTO_IP = 0;

const IPPROTO_IPV6 = 41;

const SOL_TCP = 6;

const SOL_UDP = 17;

const IPV6_UNICAST_HOPS = 16;

const IPV6_RECVPKTINFO = 49;

const IPV6_PKTINFO = 50;

const IPV6_RECVHOPLIMIT = 51;

const IPV6_HOPLIMIT = 52;

const IPV6_RECVTCLASS = 66;

const IPV6_TCLASS = 67;

const SCM_RIGHTS = 1;

const SCM_CREDENTIALS = 2;

const SO_PASSCRED = 16;

const SOCKET_EPROCLIM = 10067;

const SOCKET_ESTALE = 10070;

const SOCKET_EDISCON = 10101;

const SOCKET_SYSNOTREADY = 10091;

const SOCKET_VERNOTSUPPORTED = 10092;

const SOCKET_NOTINITIALISED = 10093;

const SOCKET_HOST_NOT_FOUND = 11001;

const SOCKET_TRY_AGAIN = 11002;

const SOCKET_NO_RECOVERY = 11003;

const SOCKET_NO_DATA = 11004;

const SOCKET_NO_ADDRESS = 11004;

const AI_PASSIVE = 1;

const AI_CANONNAME = 2;

const AI_NUMERICHOST = 4;

const AI_ADDRCONFIG = 32;

const AI_NUMERICSERV = 1024;

const AI_V4MAPPED = 8;

const AI_ALL = 16;

const TCP_DEFER_ACCEPT = 9;

const SO_INCOMING_CPU = 49;

const SO_MEMINFO = 55;

const SO_BPF_EXTENSIONS = 48;

const SKF_AD_OFF = -096;

const SKF_AD_PROTOCOL = 0;

const SKF_AD_PKTTYPE = 4;

const SKF_AD_IFINDEX = 8;

const SKF_AD_NLATTR = 12;

const SKF_AD_NLATTR_NEST = 16;

const SKF_AD_MARK = 20;

const SKF_AD_QUEUE = 24;

const SKF_AD_HATYPE = 28;

const SKF_AD_RXHASH = 32;

const SKF_AD_CPU = 36;

const SKF_AD_ALU_XOR_X = 40;

const SKF_AD_VLAN_TAG = 44;

const SKF_AD_VLAN_TAG_PRESENT = 48;

const SKF_AD_PAY_OFFSET = 52;

const SKF_AD_RANDOM = 56;

const SKF_AD_VLAN_TPID = 60;

const SKF_AD_MAX = 64;

const TCP_CONGESTION = 13;

const TCP_NOTSENT_LOWAT = 25;

const TCP_KEEPIDLE = 4;

const TCP_KEEPINTVL = 5;

const TCP_KEEPCNT = 6;

const TCP_QUICKACK = 12;

const TCP_REPAIR = 19;

const SO_ZEROCOPY = 60;

const MSG_ZEROCOPY = 67108864;

const SOCK_DCCP = 6;

const TCP_SYNCNT = 7;

const SOCK_CLOEXEC = 524288;

const SOCK_NONBLOCK = 2048;

const SO_BINDTOIFINDEX = 62;

final class Socket
{
    private function __construct() {}
}

final class AddressInfo
{
    private function __construct() {}
}

/**
 * @return AddressInfo[]|false
 */
function socket_addrinfo_lookup(string $host, null|string $service, array $hints = []): array|false
{
}

function socket_addrinfo_connect(AddressInfo $address): Socket|false
{
}

function socket_addrinfo_bind(AddressInfo $address): Socket|false
{
}

/**
 * @return array{
 *   'ai_flags': int,
 *   'ai_family': int,
 *   'ai_socktype': int,
 *   'ai_protocol': int,
 *   'ai_canonname': string,
 *   'ai_addr': array{
 *       'sin_port': int,
 *       'sin_addr': string,
 *       'sin6_port': int,
 *       'sin6_addr': string,
 *   },
 * }
 */
function socket_addrinfo_explain(AddressInfo $address): array
{
}

/**
 * @param-out array<array-key, resource> $read
 * @param-out array<array-key, resource> $write
 * @param-out array<array-key, resource> $except
 */
function socket_select(
    null|array &$read,
    null|array &$write,
    null|array &$except,
    null|int $seconds,
    int $microseconds = 0,
): int|false {
}

function socket_create(int $domain, int $type, int $protocol): Socket|false
{
}

/**
 * @param Socket $socket
 * @return resource|Socket|false
 */
function socket_export_stream(Socket $socket)
{
}

function socket_create_listen(int $port, int $backlog = 128): Socket|false
{
}

/**
 * @param-out array{Socket, Socket} $pair
 */
function socket_create_pair(int $domain, int $type, int $protocol, &$pair): bool
{
}

function socket_accept(Socket $socket): Socket|false
{
}

function socket_set_nonblock(Socket $socket): bool
{
}

function socket_set_block(Socket $socket): bool
{
}

function socket_listen(Socket $socket, int $backlog = 0): bool
{
}

function socket_close(Socket $socket): void
{
}

function socket_write(Socket $socket, string $data, null|int $length = null): int|false
{
}

function socket_read(Socket $socket, int $length, int $mode = PHP_BINARY_READ): string|false
{
}

/**
 * @param-out string $address
 * @param-out int $port
 */
function socket_getsockname(Socket $socket, &$address, &$port = null): bool
{
}

/**
 * @param-out string $address
 * @param-out int $port
 */
function socket_getpeername(Socket $socket, &$address, &$port = null): bool
{
}

function socket_connect(Socket $socket, string $address, null|int $port = null): bool
{
}

function socket_strerror(int $error_code): string
{
}

function socket_bind(Socket $socket, string $address, int $port = 0): bool
{
}

/**
 * @param-out string $data
 */
function socket_recv(Socket $socket, &$data, int $length, int $flags): int|false
{
}

function socket_send(Socket $socket, string $data, int $length, int $flags): int|false
{
}

function socket_sendmsg(Socket $socket, array $message, int $flags = 0): int|false
{
}

/**
 * @param-out string $data
 * @param-out string $address
 * @param-out int $port
 */
function socket_recvfrom(Socket $socket, &$data, int $length, int $flags, &$address, &$port = null): int|false
{
}

/**
 * @param-out array $message
 */
function socket_recvmsg(Socket $socket, array &$message, int $flags = 0): int|false
{
}

function socket_sendto(
    Socket $socket,
    string $data,
    int $length,
    int $flags,
    string $address,
    null|int $port = null,
): int|false {
}

function socket_get_option(Socket $socket, int $level, int $option): array|int|false
{
}

function socket_set_option(Socket $socket, int $level, int $option, $value): bool
{
}

function socket_shutdown(Socket $socket, int $mode = 2): bool
{
}

function socket_last_error(null|Socket $socket = null): int
{
}

function socket_clear_error(null|Socket $socket = null): void
{
}

/**
 * @param resource|Socket $stream
 */
function socket_import_stream($stream): Socket|false
{
}

function socket_cmsg_space(int $level, int $type, int $num = 0): null|int
{
}

function socket_getopt(Socket $socket, int $level, int $option): array|int|false
{
}

function socket_setopt(Socket $socket, int $level, int $option, $value): bool
{
}

function socket_wsaprotocol_info_export(Socket $socket, int $target_pid): string|false
{
}

function socket_wsaprotocol_info_import(string $info_id): Socket|false
{
}

function socket_wsaprotocol_info_release(string $info_id): bool
{
}

function socket_atmark(Socket $socket): bool
{
}
