Laracon EU Online 2021

定義済み定数

以下の定数が定義されています。 この関数の拡張モジュールが PHP 組み込みでコンパイルされているか、 実行時に動的にロードされている場合のみ使用可能です。

AF_UNIX (int)
AF_INET (int)
AF_INET6 (int)
IPv6 サポートつきでコンパイルした場合にのみ使用可能です。
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)
Windows プラットフォームでは使用できません。
MSG_EOF (int)
Windows プラットフォームでは使用できません。
SO_DEBUG (int)
SO_REUSEADDR (int)
SO_REUSEPORT (int)
この定数は、PHP 5.4.10 以降でかつソケットオプション SO_REUSEPORT に対応したプラットフォーム上でだけ使えます。 MacOS や FreeBSD などはこのソケットオプションに対応していますが、 Linux や 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)
TCP_NODELAY (int)
Nagle TCP アルゴリズムを無効にするために使用します。 PHP 5.2.7 で追加されました。
SOL_SOCKET (int)
PHP_NORMAL_READ (int)
PHP_BINARY_READ (int)
SOL_TCP (int)
SOL_UDP (int)

以下の定数は Windows でのみ定義されています。

SOCKET_EINTR (int)
Interrupted system call.
SOCKET_EBADF (int)
Bad file 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)

以下の定数は UNIX ライクなプラットフォームでのみ使用可能です。 各定数は、そのプラットフォーム上で同等のものが定義されている場合にのみ定義されています。

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.
add a note add a note

User Contributed Notes 4 notes

up
15
Anonymous
8 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
4
gvgvgvijayan at gmail dot com
7 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
0
kenverhaegen at gmail dot com
7 months ago
Seems like SOCKET_EAGAIN is an alias of SOCKET_EWOULDBLOCK (int 11)
up
0
yyb8 at vip dot qq dot com
3 years ago
note:Linux kernel 3.9  now support SO_REUSEPORT option
To Top