PHP 8.3.4 Released!

Constantes predefinidas

Estas constantes están definidas por esta extensión y estarán disponibles sólo cuando la extensión haya sido compilada con PHP, o bien sea cargada dinámicamente en ejecución.

AF_UNIX (integer)
AF_INET (integer)
AF_INET6 (integer)
Sólo disponible si se compila con soporte para IPv6.
SOCK_STREAM (integer)
SOCK_DGRAM (integer)
SOCK_RAW (integer)
SOCK_SEQPACKET (integer)
SOCK_RDM (integer)
MSG_OOB (integer)
MSG_WAITALL (integer)
MSG_PEEK (integer)
MSG_DONTROUTE (integer)
MSG_EOR (integer)
No disponible en plataformas Windows.
MSG_EOF (integer)
No disponible en plataformas Windows.
SO_DEBUG (integer)
SO_REUSEADDR (integer)
SO_REUSEPORT (integer)
Esta constante únicamente está disponible en PHP 5.4.10 o posterior en plataformas que admiten la opción de socket SO_REUSEPORT : esto incluye macOS y FreeBSD, pero no incluye Linux o Windows.
SO_KEEPALIVE (integer)
SO_DONTROUTE (integer)
SO_LINGER (integer)
SO_BROADCAST (integer)
SO_OOBINLINE (integer)
SO_SNDBUF (integer)
SO_RCVBUF (integer)
SO_SNDLOWAT (integer)
SO_RCVLOWAT (integer)
SO_SNDTIMEO (integer)
SO_RCVTIMEO (integer)
SO_TYPE (integer)
SO_ERROR (integer)
TCP_NODELAY (integer)
Usada para deshabilitar el algoritmo Nagle TCP. Añadido en PHP 5.2.7.
SOL_SOCKET (integer)
PHP_NORMAL_READ (integer)
PHP_BINARY_READ (integer)
SOL_TCP (integer)
SOL_UDP (integer)

Las siguientes constantes están definidas bajo plataformas Windows y similares a UNIX. Cada constante sólo está definida si su equivalente está disponible en la plataforma.

SOCKET_EINTR (integer)
Llamada al sistema interrumpida
SOCKET_EBADF (integer)
Número de fichero corrupto.
SOCKET_EACCES (integer)
Permiso denegado.
SOCKET_EFAULT (integer)
Dirección corrupta.
SOCKET_EINVAL (integer)
Argumento no válido
SOCKET_EMFILE (integer)
Demasiados ficheros abiertos.
SOCKET_ENAMETOOLONG (integer)
Nombre de fichero demasiado largo.
SOCKET_ENOTEMPTY (integer)
Directorio no vacío.
SOCKET_ELOOP (integer)
Demasiados enlaces simbólicos encontrados.
SOCKET_EWOULDBLOCK (integer)
La operación podría bloquear.
SOCKET_EREMOTE (integer)
El objeto es remoto.
SOCKET_EUSERS (integer)
Demasiados usuarios.
SOCKET_ENOTSOCK (integer)
Operación de socket en algo que no es socket.
SOCKET_EDESTADDRREQ (integer)
Se requiere la dirección de destino.
SOCKET_EMSGSIZE (integer)
Mensaje demasiado largo.
SOCKET_EPROTOTYPE (integer)
Tipo erróneo de protocolo para el socket.
SOCKET_EPROTONOSUPPORT (integer)
Tipo de socket no soportado.
SOCKET_ESOCKTNOSUPPORT (integer)
Tipo de socket no soportado.
SOCKET_EOPNOTSUPP (integer)
Operación no soportada en el extremo del transporte.
SOCKET_EPFNOSUPPORT (integer)
Familia de protocolos no soportada.
SOCKET_EAFNOSUPPORT (integer)
Familia de direcciones no soportada por el protocolo.
SOCKET_EADDRNOTAVAIL (integer)
No se puede asignar la dirección solicitada.
SOCKET_ENETDOWN (integer)
La red está caída.
SOCKET_ENETUNREACH (integer)
La red es inalcanzable.
SOCKET_ENETRESET (integer)
La conexión a la red se cayó a causa de un reinicio.
SOCKET_ECONNABORTED (integer)
Algún software causó el aborto de conexión.
SOCKET_ECONNRESET (integer)
Conexión reiniciada por un par.
SOCKET_ENOBUFS (integer)
No hay espacio de buffer disponible.
SOCKET_EISCONN (integer)
El extremo de transporte ya está conectado.
SOCKET_ENOTCONN (integer)
El extremo de transporte no está conectado.
SOCKET_ESHUTDOWN (integer)
No se puede enviar después del cierre del extremo de transporte.
SOCKET_ETIMEDOUT (integer)
La conexión agotó su tiempo.
SOCKET_ECONNREFUSED (integer)
Conexión rechazada.
SOCKET_EHOSTDOWN (integer)
El host está caído.
SOCKET_EHOSTUNREACH (integer)
No hay ruta hacia el host.
SOCKET_EALREADY (integer)
La operación ya está en progreso.
SOCKET_EINPROGRESS (integer)
La operación ahora está en progreso.

Las siguientes constantes sólo están definidas bajo Windows.

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

Las siguientes constantes sólo están disponibles en plataformas similares a UNIX. Cada constante sólo está definida si su equivalente está disponible en la plataforma.

SOCKET_EPERM (integer)
Operación no permitida.
SOCKET_ENOENT (integer)
No existe el archivo o directorio.
SOCKET_EIO (integer)
Error I/O (Entrada/Salida).
SOCKET_ENXIO (integer)
No existe el dispositivo o dirección.
SOCKET_E2BIG (integer)
Lista de argumentos demasiado larga.
SOCKET_EAGAIN (integer)
Intentar de nuevo.
SOCKET_ENOMEM (integer)
Memoria insuficiente.
SOCKET_ENOTBLK (integer)
Se requiere un dispositivo de bloque.
SOCKET_EBUSY (integer)
Dispositivo o recurso ocupado.
SOCKET_EEXIST (integer)
El archivo ya exite.
SOCKET_EXDEV (integer)
Vínculo de dispositivo cruzado.
SOCKET_ENODEV (integer)
No existe el dispositivo.
SOCKET_ENOTDIR (integer)
No es un directorio.
SOCKET_EISDIR (integer)
Es un directorio.
SOCKET_ENFILE (integer)
Desbordamiento de la tabla de archivos.
SOCKET_ENOTTY (integer)
No es un terminal informático.
SOCKET_ENOSPC (integer)
No queda espacio en el dispositivo.
SOCKET_ESPIPE (integer)
Búsqueda ilegal.
SOCKET_EROFS (integer)
Sistema de archivos de sólo lectura.
Demasiados enlaces.
SOCKET_EPIPE (integer)
Tubería rota.
SOCKET_ENOLCK (integer)
No hay disponibles bloqueos de registro.
SOCKET_ENOSYS (integer)
Función no implementada.
SOCKET_ENOMSG (integer)
No hay mensaje del tipo deseado.
SOCKET_EIDRM (integer)
Identificador eliminado.
SOCKET_ECHRNG (integer)
Número de canal fuera de rango.
SOCKET_EL2NSYNC (integer)
Nivel 2 no sincronizado.
SOCKET_EL3HLT (integer)
Nivel 3 detenido.
SOCKET_EL3RST (integer)
Nivel 3 reiniciado.
SOCKET_ELNRNG (integer)
Número de enlace fuera de rango.
SOCKET_EUNATCH (integer)
Controlador de protocolo no adjunto.
SOCKET_ENOCSI (integer)
No hay disponible una estructura CSI.
SOCKET_EL2HLT (integer)
Nivel 2 detenido.
SOCKET_EBADE (integer)
Intercambio no válido.
SOCKET_EBADR (integer)
Descriptor de solicitud no válido.
SOCKET_EXFULL (integer)
Intercambio lleno.
SOCKET_ENOANO (integer)
Sin ánodo.
SOCKET_EBADRQC (integer)
Código de solicitud no válido.
SOCKET_EBADSLT (integer)
Ranura no válida.
SOCKET_ENOSTR (integer)
El dispositivo no es un flujo.
SOCKET_ENODATA (integer)
No hay información disponible.
SOCKET_ETIME (integer)
Temporizador caducado.
SOCKET_ENOSR (integer)
Sin recursos de flujos.
SOCKET_ENONET (integer)
La máquina no está en la red.
El enlace ha sido servido.
SOCKET_EADV (integer)
Error de anuncio.
SOCKET_ESRMNT (integer)
Error de Srmount.
SOCKET_ECOMM (integer)
Error de comunicación al enviar.
SOCKET_EPROTO (integer)
Error de protocolo.
SOCKET_EMULTIHOP (integer)
Se intentó un multi-salto (hop).
SOCKET_EBADMSG (integer)
No es un mensaje de datos.
SOCKET_ENOTUNIQ (integer)
El nombre no es único en la red.
SOCKET_EBADFD (integer)
Descriptor de archivo en mal estado.
SOCKET_EREMCHG (integer)
Dirección remota cambiada.
SOCKET_ERESTART (integer)
La llamada al sistema interrumpida debería ser reiniciada.
SOCKET_ESTRPIPE (integer)
Error de tubería de flujos.
SOCKET_EPROTOOPT (integer)
Protocolo no disponible.
SOCKET_ADDRINUSE (integer)
La dirección ya está en uso.
SOCKET_ETOOMANYREFS (integer)
Demasiadas referencias: unión no posible.
SOCKET_EISNAM (integer)
Es un archivo de tipo nominado.
SOCKET_EREMOTEIO (integer)
Error de E/S remoto.
SOCKET_EDQUOT (integer)
Cuota excedida.
SOCKET_ENOMEDIUM (integer)
No se encontró el medio.
SOCKET_EMEDIUMTYPE (integer)
Tipo de medio erróneo.
add a note

User Contributed Notes 4 notes

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