List of socket-related error codes in PHP

This is a memo for me, to have all or at least most important and most common error codes, that can be returned by any socket-related function (socket_*) in PHP, handy in one single blog post.

Here they are:

  • ENOTSOCK (88) — socket operation on non-socket,
  • EDESTADDRREQ (89) — destination address required,
  • EMSGSIZE (90) — message too long,
  • EPROTOTYPE (91) — protocol wrong type for socket,
  • ENOPROTOOPT (92) — protocol not available,
  • EPROTONOSUPPORT (93) — protocol not supported,
  • ESOCKTNOSUPPORT (94) — socket type not supported,
  • EOPNOTSUPP (95) — operation not supported on transport endpoint,
  • EPFNOSUPPORT (96) — protocol family not supported,
  • EAFNOSUPPORT (97) — address family not supported by protocol,
  • EADDRINUSE (98) — address already in use,
  • EADDRNOTAVAIL (99) — cannot assign requested address,
  • ENETDOWN (100) — network is down,
  • ENETUNREACH (101) — network is unreachable,
  • ENETRESET (102) — network dropped connection because of reset,
  • ECONNABORTED (103) — software caused connection abort,
  • ECONNRESET (104) — connection reset by peer,
  • ENOBUFS (105) — no buffer space available,
  • EISCONN (106) — transport endpoint is already connected,
  • ENOTCONN (107) — transport endpoint is not connected,
  • ESHUTDOWN (108) — cannot send after transport endpoint shutdown,
  • ETOOMANYREFS (109) — too many references: cannot splice,
  • ETIMEDOUT (110) — connection timed out,
  • ECONNREFUSED (111) — connection refused,
  • EHOSTDOWN (112) — host is down,
  • EHOSTUNREACH (113) — no route to host,
  • EALREADY (114) — operation already in progress,
  • EINPROGRESS (115) — operation now in progress,
  • EREMOTEIO (121) — remote I/O error,
  • ECANCELED (125) — operation cancelled.

You can get last socket error code using socket_last_error() PHP function.

Leave a Reply