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)
AF_INET (int)
AF_INET6 (int)
Only available if compiled with IPv6 support.
AF_DIVERT (int)
Available as of PHP 8.3.0 (FreeBSD only)
SOCK_STREAM (int)
SOCK_DGRAM (int)
SOCK_RAW (int)
SOCK_SEQPACKET (int)
SOCK_RDM (int)
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)
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
add a note add a note

User Contributed Notes 4 notes

up
15
Anonymous
12 years ago
We can know sockets constants values with :

<?php
$a
= get_defined_constants(TRUE) ;
foreach (
$a['sockets'] as $constant => $value ) {
   
printf("%-25s %d\r\n", $constant, $value) ;
}
?>

AF_UNIX                   1
AF_INET                   2
AF_INET6                  23
SOCK_STREAM               1
SOCK_DGRAM                2
SOCK_RAW                  3
SOCK_SEQPACKET            5
SOCK_RDM                  4
MSG_OOB                   1
MSG_WAITALL               0
MSG_PEEK                  2
MSG_DONTROUTE             4
SO_DEBUG                  1
SO_REUSEADDR              4
SO_KEEPALIVE              8
SO_DONTROUTE              16
SO_LINGER                 128
SO_BROADCAST              32
SO_OOBINLINE              256
SO_SNDBUF                 4097
SO_RCVBUF                 4098
SO_SNDLOWAT               4099
SO_RCVLOWAT               4100
SO_SNDTIMEO               4101
SO_RCVTIMEO               4102
SO_TYPE                   4104
SO_ERROR                  4103
SOL_SOCKET                65535
SOMAXCONN                 2147483647
TCP_NODELAY               1
PHP_NORMAL_READ           1
PHP_BINARY_READ           2
SOCKET_EINTR              10004
SOCKET_EBADF              10009
SOCKET_EACCES             10013
SOCKET_EFAULT             10014
SOCKET_EINVAL             10022
SOCKET_EMFILE             10024
SOCKET_EWOULDBLOCK        10035
SOCKET_EINPROGRESS        10036
SOCKET_EALREADY           10037
SOCKET_ENOTSOCK           10038
SOCKET_EDESTADDRREQ       10039
SOCKET_EMSGSIZE           10040
SOCKET_EPROTOTYPE         10041
SOCKET_ENOPROTOOPT        10042
SOCKET_EPROTONOSUPPORT    10043
SOCKET_ESOCKTNOSUPPORT    10044
SOCKET_EOPNOTSUPP         10045
SOCKET_EPFNOSUPPORT       10046
SOCKET_EAFNOSUPPORT       10047
SOCKET_EADDRINUSE         10048
SOCKET_EADDRNOTAVAIL      10049
SOCKET_ENETDOWN           10050
SOCKET_ENETUNREACH        10051
SOCKET_ENETRESET          10052
SOCKET_ECONNABORTED       10053
SOCKET_ECONNRESET         10054
SOCKET_ENOBUFS            10055
SOCKET_EISCONN            10056
SOCKET_ENOTCONN           10057
SOCKET_ESHUTDOWN          10058
SOCKET_ETOOMANYREFS       10059
SOCKET_ETIMEDOUT          10060
SOCKET_ECONNREFUSED       10061
SOCKET_ELOOP              10062
SOCKET_ENAMETOOLONG       10063
SOCKET_EHOSTDOWN          10064
SOCKET_EHOSTUNREACH       10065
SOCKET_ENOTEMPTY          10066
SOCKET_EPROCLIM           10067
SOCKET_EUSERS             10068
SOCKET_EDQUOT             10069
SOCKET_ESTALE             10070
SOCKET_EREMOTE            10071
SOCKET_EDISCON            10101
SOCKET_SYSNOTREADY        10091
SOCKET_VERNOTSUPPORTED    10092
SOCKET_NOTINITIALISED     10093
SOCKET_HOST_NOT_FOUND     11001
SOCKET_TRY_AGAIN          11002
SOCKET_NO_RECOVERY        11003
SOCKET_NO_DATA            11004
SOCKET_NO_ADDRESS         11004
SOL_TCP                   6
SOL_UDP                   17
up
5
gvgvgvijayan at gmail dot com
11 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
4 years ago
Seems like SOCKET_EAGAIN is an alias of SOCKET_EWOULDBLOCK (int 11)
up
-1
yyb8 at vip dot qq dot com
7 years ago
note:Linux kernel 3.9  now support SO_REUSEPORT option
To Top