Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

AF_UNIX (int )

Socket address family of filesystem pathnames in the Unix Domain.

AF_INET (int )

Socket address family of IPv4 in the Internet Domain.

AF_INET6 (int )

Socket address family of IPv6 in the Internet Domain. Only available if compiled with IPv6 support.

AF_DIVERT (int )

Socket address family for the FreeBSD divert(4) interface, used to receive packets diverted by the firewall. Available as of PHP 8.3.0 (FreeBSD only).

AF_PACKET (int )

Socket address family for low-level packet sockets, used to send and receive raw packets at the device-driver (OSI layer 2) level. Available as of PHP 8.5.0 (Linux only).

SOCK_STREAM (int )
SOCK_DGRAM (int )
SOCK_RAW (int )
SOCK_SEQPACKET (int )
SOCK_RDM (int )
SOCK_CONN_DGRAM (int )

Set the socket to a connection-oriented datagram. Available as of PHP 8.4.0. (NetBSD only)

SOCK_DCCP (int )

Set the socket to a datagram congestion control protocol. Available as of PHP 8.4.0. (NetBSD only)

SOCK_NONBLOCK (int )

Set the non-blocking socket status flag. Available as of PHP 8.4.0.

SOCK_CLOEXEC (int )

Set the close-on-exec socket status flag. Available as of PHP 8.4.0.

MSG_OOB (int )
MSG_WAITALL (int )
MSG_PEEK (int )
MSG_DONTROUTE (int )
MSG_EOR (int )

Not available on Windows platforms.

MSG_EOF (int )

Not available on Windows platforms.

MSG_ZEROCOPY (int )

Available as of PHP 8.2.0

SO_DEBUG (int )
SO_REUSEADDR (int )
SO_REUSEPORT (int )

This constant is only available on platforms that support the SO_REUSEPORT socket option: this includes Linux, macOS and *BSD, but does not include Windows.

SO_KEEPALIVE (int )
SO_DONTROUTE (int )
SO_LINGER (int )
SO_BROADCAST (int )
SO_OOBINLINE (int )
SO_SNDBUF (int )
SO_RCVBUF (int )
SO_SNDLOWAT (int )
SO_RCVLOWAT (int )
SO_SNDTIMEO (int )
SO_RCVTIMEO (int )
SO_TYPE (int )
SO_ERROR (int )
SO_ZEROCOPY (int )

Available as of PHP 8.2.0

TCP_NODELAY (int )

Used to disable Nagle TCP algorithm.

TCP_KEEPCNT (int )

Available as of PHP 8.2.0

TCP_KEEPIDLE (int )

Available as of PHP 8.2.0

TCP_KEEPINTVL (int )

Available as of PHP 8.2.0

TCP_KEEPALIVE (int )

Available as of PHP 8.2.0

TCP_NOTSENT_LOWAT (int )

Available as of PHP 8.2.0

SO_MARK (int )

Available as of PHP 8.1.0

Available as of PHP 8.1.0

SO_RTABLE (int )

Available as of PHP 8.2.0

SO_ACCEPTFILTER (int )

Available as of PHP 8.1.0

SO_DONTTRUNC (int )

Available as of PHP 8.1.0

SO_WANTMORE (int )

Available as of PHP 8.1.0

SO_INCOMING_CPU (int )

Available as of PHP 8.2.0

SO_MEMINFO (int )

Available as of PHP 8.2.0

SO_BPF_EXTENSIONS (int )

Available as of PHP 8.2.0

SO_SETFIB (int )

Available as of PHP 8.2.0

SO_ATTACH_REUSEPORT_CBPF (int )

Available as of PHP 8.3.0 (Linux only)

SO_DETACH_BPF (int )

Available as of PHP 8.3.0 (Linux only)

SO_DETACH_FILTER (int )

Available as of PHP 8.3.0 (Linux only)

SO_RERROR (int )

Available as of PHP 8.3.0 (NetBSD only)

SO_ZEROIZE (int )

Available as of PHP 8.3.0 (OpenBSD only)

SO_SPLICE (int )

Available as of PHP 8.3.0 (OpenBSD only)

SO_REUSEPORT_LB (int )

Available as of PHP 8.3.0 (FreeBSD only)

SOL_FILTER (int )

Available as of PHP 8.2.0

SOL_UDPLITE (int )

Available as of PHP 8.3.0

UDPLITE_RECV_CSCOV (int )

Available as of PHP 8.3.0

UDPLITE_SEND_CSCOV (int )

Available as of PHP 8.3.0

TCP_DEFER_ACCEPT (int )

Available as of PHP 8.1.0

TCP_CONGESTION (int )

Available as of PHP 8.2.0

TCP_QUICKACK (int )

Available as of PHP 8.3.0 (Linux only)

TCP_REPAIR (int )

Available as of PHP 8.3.0 (Linux only)

TCP_SYNCNT (int )

Set the number of SYN retransmits that TCP should send before aborting the attempt to connect. Available as of PHP 8.4.0 (Linux only)

IP_DONTFRAG (int )

Available as of PHP 8.3.0 (FreeBSD only)

IP_MTU_DISCOVER (int )

Available as of PHP 8.3.0 (Linux only)

IP_PMTUDISC_DO (int )

Available as of PHP 8.3.0 (Linux only)

IP_PMTUDISC_DONT (int )

Available as of PHP 8.3.0 (Linux only)

IP_PMTUDISC_WANT (int )

Available as of PHP 8.3.0 (Linux only)

IP_PMTUDISC_PROBE (int )

Available as of PHP 8.3.0 (Linux only)

IP_PMTUDISC_INTERFACE (int )

Available as of PHP 8.3.0 (Linux only)

IP_PMTUDISC_OMIT (int )

Available as of PHP 8.3.0 (Linux only)

IP_BIND_ADDRESS_NO_PORT (int )

Available as of PHP 8.3.0 (Linux only)

SOL_SOCKET (int )
PHP_NORMAL_READ (int )
PHP_BINARY_READ (int )
SOL_TCP (int )
SOL_UDP (int )

The following constants are defined under Windows and UNIX-like platforms. Each constant is only defined if their equal is available on the platform.

SOCKET_EINTR (int )

Interrupted system call.

SOCKET_EBADF (int )

Bad file descriptor number.

SOCKET_EACCES (int )

Permission denied.

SOCKET_EFAULT (int )

Bad address.

SOCKET_EINVAL (int )

Invalid argument.

SOCKET_EMFILE (int )

Too many open files.

SOCKET_ENAMETOOLONG (int )

File name too long.

SOCKET_ENOTEMPTY (int )

Directory not empty.

SOCKET_ELOOP (int )

Too many symbolic links encountered.

SOCKET_EWOULDBLOCK (int )

Operation would block.

SOCKET_EREMOTE (int )

Object is remote.

SOCKET_EUSERS (int )

Too many users.

SOCKET_ENOTSOCK (int )

Socket operation on non-socket.

SOCKET_EDESTADDRREQ (int )

Destination address required.

SOCKET_EMSGSIZE (int )

Message too long.

SOCKET_EPROTOTYPE (int )

Protocol wrong type for socket.

SOCKET_EPROTONOSUPPORT (int )

Protocol not supported.

SOCKET_ESOCKTNOSUPPORT (int )

Socket type not supported.

SOCKET_EOPNOTSUPP (int )

Operation not supported on transport endpoint.

SOCKET_EPFNOSUPPORT (int )

Protocol family not supported.

SOCKET_EAFNOSUPPORT (int )

Address family not supported by protocol.

SOCKET_EADDRNOTAVAIL (int )

Cannot assign requested address.

SOCKET_ENETDOWN (int )

Network is down.

SOCKET_ENETUNREACH (int )

Network is unreachable.

SOCKET_ENETRESET (int )

Network dropped connection because of reset.

SOCKET_ECONNABORTED (int )

Software caused connection abort.

SOCKET_ECONNRESET (int )

Connection reset by peer.

SOCKET_ENOBUFS (int )

No buffer space available.

SOCKET_EISCONN (int )

Transport endpoint is already connected.

SOCKET_ENOTCONN (int )

Transport endpoint is not connected.

SOCKET_ESHUTDOWN (int )

Cannot send after transport endpoint shutdown.

SOCKET_ETIMEDOUT (int )

Connection timed out.

SOCKET_ECONNREFUSED (int )

Connection refused.

SOCKET_EHOSTDOWN (int )

Host is down.

SOCKET_EHOSTUNREACH (int )

No route to host.

SOCKET_EALREADY (int )

Operation already in progress.

SOCKET_EINPROGRESS (int )

Operation now in progress.

The following constants are only defined under Windows.

SOCKET_ENOPROTOOPT (int )
SOCKET_EADDRINUSE (int )
SOCKET_ETOOMYREFS (int )
SOCKET_EPROCLIM (int )
SOCKET_EDUOT (int )
SOCKET_ESTALE (int )
SOCKET_EDISCON (int )
SOCKET_SYSNOTREADY (int )
SOCKET_VERNOTSUPPORTED (int )
SOCKET_NOTINITIALISED (int )
SOCKET_HOST_NOT_FOUND (int )
SOCKET_TRY_AGAIN (int )
SOCKET_NO_RECOVERY (int )
SOCKET_NO_DATA (int )
SOCKET_NO_ADDRESS (int )

The following constants are only available on UNIX-like platforms. Each constant is only defined if their equal is available on the platform.

SOCKET_EPERM (int )

Operation not permitted.

SOCKET_ENOENT (int )

No such file or directory.

SOCKET_EIO (int )

I/O error.

SOCKET_ENXIO (int )

No such device or address.

SOCKET_E2BIG (int )

Arg list too long.

SOCKET_EAGAIN (int )

Try again.

SOCKET_ENOMEM (int )

Out of memory.

SOCKET_ENOTBLK (int )

Block device required.

SOCKET_EBUSY (int )

Device or resource busy.

SOCKET_EEXIST (int )

File exists.

SOCKET_EXDEV (int )

Cross-device link.

SOCKET_ENODEV (int )

No such device.

SOCKET_ENOTDIR (int )

Not a directory.

SOCKET_EISDIR (int )

Is a directory.

SOCKET_ENFILE (int )

File table overflow.

SOCKET_ENOTTY (int )

Not a typewriter.

SOCKET_ENOSPC (int )

No space left on device.

SOCKET_ESPIPE (int )

Illegal seek.

SOCKET_EROFS (int )

Read-only file system.

Too many links.

SOCKET_EPIPE (int )

Broken pipe.

SOCKET_ENOLCK (int )

No record locks available.

SOCKET_ENOSYS (int )

Function not implemented.

SOCKET_ENOMSG (int )

No message of desired type.

SOCKET_EIDRM (int )

Identifier removed.

SOCKET_ECHRNG (int )

Channel number out of range.

SOCKET_EL2NSYNC (int )

Level 2 not synchronized.

SOCKET_EL3HLT (int )

Level 3 halted.

SOCKET_EL3RST (int )

Level 3 reset.

SOCKET_ELNRNG (int )

Link number out of range.

SOCKET_EUNATCH (int )

Protocol driver not attached.

SOCKET_ENOCSI (int )

No CSI structure available.

SOCKET_EL2HLT (int )

Level 2 halted.

SOCKET_EBADE (int )

Invalid exchange.

SOCKET_EBADR (int )

Invalid request descriptor.

SOCKET_EXFULL (int )

Exchange full.

SOCKET_ENOANO (int )

No anode.

SOCKET_EBADRQC (int )

Invalid request code.

SOCKET_EBADSLT (int )

Invalid slot.

SOCKET_ENOSTR (int )

Device not a stream.

SOCKET_ENODATA (int )

No data available.

SOCKET_ETIME (int )

Timer expired.

SOCKET_ENOSR (int )

Out of streams resources.

SOCKET_ENONET (int )

Machine is not on the network.

Link has been severed.

SOCKET_EADV (int )

Advertise error.

SOCKET_ESRMNT (int )

Srmount error.

SOCKET_ECOMM (int )

Communication error on send.

SOCKET_EPROTO (int )

Protocol error.

SOCKET_EMULTIHOP (int )

Multihop attempted.

SOCKET_EBADMSG (int )

Not a data message.

SOCKET_ENOTUNIQ (int )

Name not unique on network.

SOCKET_EBADFD (int )

File descriptor in bad state.

SOCKET_EREMCHG (int )

Remote address changed.

SOCKET_ERESTART (int )

Interrupted system call should be restarted.

SOCKET_ESTRPIPE (int )

Streams pipe error.

SOCKET_EPROTOOPT (int )

Protocol not available.

SOCKET_ADDRINUSE (int )

Address already in use.

SOCKET_ETOOMANYREFS (int )

Too many references: cannot splice.

SOCKET_EISNAM (int )

Is a named type file.

SOCKET_EREMOTEIO (int )

Remote I/O error.

SOCKET_EDQUOT (int )

Quota exceeded.

SOCKET_ENOMEDIUM (int )

No medium found.

SOCKET_EMEDIUMTYPE (int )

Wrong medium type.

SCM_RIGHTS (int )

Send or receive a set of open file descriptors from another process.

SCM_CREDENTIALS (int )
SCM_CREDS (int )

Available as of PHP 8.2.0

SCM_CREDS2 (int )

Available as of PHP 8.2.0

LOCAL_CREDS (int )

Available as of PHP 8.2.0

LOCAL_CREDS_PERSISTENT (int )

Available as of PHP 8.2.0

SKF_AD_OFF (int )

Available as of PHP 8.2.0

SKF_AD_PROTOCOL (int )

Available as of PHP 8.2.0

SKF_AD_PKTTYPE (int )

Available as of PHP 8.2.0

SKF_AD_IFINDEX (int )

Available as of PHP 8.2.0

SKF_AD_NLATTR (int )

Available as of PHP 8.2.0

SKF_AD_NLATTR_NEST (int )

Available as of PHP 8.2.0

SKF_AD_MARK (int )

Available as of PHP 8.2.0

SKF_AD_QUEUE (int )

Available as of PHP 8.2.0

SKF_AD_HATYPE (int )

Available as of PHP 8.2.0

SKF_AD_RXHASH (int )

Available as of PHP 8.2.0

SKF_AD_CPU (int )

Available as of PHP 8.2.0

SKF_AD_ALU_XOR_X (int )

Available as of PHP 8.2.0

SKF_AD_VLAN_TAG (int )

Available as of PHP 8.2.0

SKF_AD_VLAN_TAG_PRESENT (int )

Available as of PHP 8.2.0

SKF_AD_PAY_OFFSET (int )

Available as of PHP 8.2.0

SKF_AD_RANDOM (int )

Available as of PHP 8.2.0

SKF_AD_VLAN_TPID (int )

Available as of PHP 8.2.0

SKF_AD_MAX (int )

Available as of PHP 8.2.0

AI_ADDRCONFIG (int )
AI_ALL (int )
AI_CANONIDN (int )
AI_CANONNAME (int )
AI_IDN (int )
AI_NUMERICHOST (int )
AI_NUMERICSERV (int )
AI_PASSIVE (int )
AI_V4MAPPED (int )
FIL_ATTACH (int )
FIL_DETACH (int )
IPPROTO_IP (int )
IPPROTO_IPV6 (int )
IPV6_HOPLIMIT (int )
IPV6_MULTICAST_HOPS (int )
IPV6_MULTICAST_IF (int )
IPV6_MULTICAST_LOOP (int )
IPV6_PKTINFO (int )
IPV6_RECVHOPLIMIT (int )
IPV6_RECVPKTINFO (int )
IPV6_RECVTCLASS (int )
IPV6_TCLASS (int )
IPV6_UNICAST_HOPS (int )
IPV6_V6ONLY (int )
IP_MULTICAST_IF (int )
IP_MULTICAST_LOOP (int )
IP_MULTICAST_TTL (int )
IP_PORTRANGE (int )

Set the port range used for selecting a local port number. Available as of PHP 8.4.0. (FreeBSD/NetBSD/OpenBSD only)

IP_PORTRANGE_DEFAULT (int )

Use the default range of port values. Available as of PHP 8.4.0. (FreeBSD/NetBSD/OpenBSD only)

IP_PORTRANGE_HIGH (int )

Use a high range of port values. Available as of PHP 8.4.0. (FreeBSD/NetBSD/OpenBSD only)

IP_PORTRANGE_LOW (int )

Use a low range of port values. Available as of PHP 8.4.0. (FreeBSD/NetBSD/OpenBSD only)

MCAST_BLOCK_SOURCE (int )
MCAST_JOIN_GROUP (int )
MCAST_JOIN_SOURCE_GROUP (int )
MCAST_LEAVE_GROUP (int )
MCAST_LEAVE_SOURCE_GROUP (int )
MCAST_UNBLOCK_SOURCE (int )
MSG_CMSG_CLOEXEC (int )
MSG_CONFIRM (int )
MSG_CTRUNC (int )
MSG_DONTWAIT (int )
MSG_ERRQUEUE (int )
MSG_MORE (int )
MSG_NOSIGNAL (int )
MSG_TRUNC (int )
MSG_WAITFORONE (int )
SOL_LOCAL (int )
SOMAXCONN (int )
SO_BINDTODEVICE (int )
SO_FAMILY (int )
SO_LABEL (int )
SO_LISTENQLEN (int )
SO_LISTENQLIMIT (int )
SO_PASSCRED (int )
SO_PEERLABEL (int )
SO_EXCLUSIVEADDRUSE (int )

Prevents other sockets from being forcibly bound to the same address and port. Available as of PHP 8.4.0. (Windows only)

SO_EXCLBIND (int )

Enable/disable exclusive binding of the socket. Available as of PHP 8.4.0. (Solaris only)

SO_NOSIGPIPE (int )

Controls generation of SIGPIPE for the socket. Available as of PHP 8.4.0. (macOs and FreeBSD only)

SO_LINGER_SEC (int )

Similar to SO_LINGER but lingering is in seconds as opposed to time clicks on macOs. Available as of PHP 8.4.0. (macOs only)

SO_BINDTOIFINDEX (int )

Bind a socket to a specific network interface by its index. Available as of PHP 8.4.0.

SHUT_RD (int )

Disables further receive operations on the socket. Used with socket_shutdown() . Available as of PHP 8.5.0.

SHUT_WR (int )

Disables further send operations on the socket. Used with socket_shutdown() . Available as of PHP 8.5.0.

SHUT_RDWR (int )

Disables further send and receive operations on the socket. Used with socket_shutdown() . Available as of PHP 8.5.0.

UDP_SEGMENT (int )

Sets the maximum size of UDP Generic Segmentation Offload (GSO) segments, allowing multiple datagrams to be sent in a single system call. Available on Linux only. Available as of PHP 8.5.0.

SO_BUSY_POLL (int )

Sets the approximate time in microseconds to busy poll on a blocking receive when there is no data. This reduces latency at the cost of CPU. Available on Linux only. Available as of PHP 8.5.0.

IP_BINDANY (int )

Allows binding a socket to any address, even if it is not local. Available on FreeBSD, NetBSD, and OpenBSD only. Available as of PHP 8.5.0.

TCP_FUNCTION_BLK (int )

Selects the TCP stack (function block) used by the socket. With socket_set_option() the value is the name of the stack as a string ; socket_get_option() returns an array with the function_set_name and pcbcnt keys. Available on FreeBSD only. Available as of PHP 8.5.0.

TCP_FUNCTION_ALIAS (int )

Retrieves the alias of the TCP stack used by the socket, as an array with the function_set_name and pcbcnt keys. Available on FreeBSD only. Available as of PHP 8.5.0.

TCP_REUSPORT_LB_NUMA (int )

Controls NUMA domain affinity for load-balanced port reuse. Available on FreeBSD only. Available as of PHP 8.5.0.

TCP_REUSPORT_LB_NUMA_NODOM (int )

Constant value for TCP_REUSPORT_LB_NUMA indicating no NUMA domain affinity. Available on FreeBSD only. Available as of PHP 8.5.0.

TCP_REUSPORT_LB_NUMA_CURDOM (int )

Constant value for TCP_REUSPORT_LB_NUMA indicating affinity for the current NUMA domain. Available on FreeBSD only. Available as of PHP 8.5.0.

TCP_BBR_ALGORITHM (int )

Socket option related to the BBR (Bottleneck Bandwidth and Round-trip propagation time) congestion control algorithm. Available on FreeBSD only. Available as of PHP 8.5.0.

IPPROTO_ICMP (int )

Internet Control Message Protocol (ICMP) protocol number, used when creating raw sockets. Available as of PHP 8.5.0.

IPPROTO_ICMPV6 (int )

Internet Control Message Protocol version 6 (ICMPv6) protocol number, used when creating raw IPv6 sockets. Available as of PHP 8.5.0.

Found A Problem?

Learn How To Improve This Page • Submit a Pull Request • Report a Bug
+add a note

User Contributed Notes 2 notes

up
3
gvgvgvijayan at gmail dot com
13 years ago
$a = get_defined_constants(TRUE);
foreach ($a as $k => $v) {
 printf('%-25s <br/>', $k);
 foreach ($v as $k => $v) {
 printf('&nbsp;&nbsp;&nbsp;&nbsp--->%-25s %d<br/>', $k, $v);
 }
}
this may look duplicate for previous anonymous post but that code snippet only return 1 for constants value
1-->first called the get_defined_constants by passing argument true to categorize the data
2-->then using foreach iterate over index of the array
3-->here printf is used to print title of the category
4-->then it move on to interrior array and display the list of contants available in each category along with its value
up
1
kenverhaegen at gmail dot com
6 years ago
Seems like SOCKET_EAGAIN is an alias of SOCKET_EWOULDBLOCK (int 11)
+add a note

AltStyle によって変換されたページ (->オリジナル) /