@@ -81,7 +81,10 @@ public function __construct($fd, LoopInterface $loop = null)
8181 $ fd = (int ) $ m [1 ];
8282 }
8383 if (!\is_int ($ fd ) || $ fd < 0 || $ fd >= \PHP_INT_MAX ) {
84- throw new \InvalidArgumentException ('Invalid FD number given ' );
84+ throw new \InvalidArgumentException (
85+ 'Invalid FD number given (EINVAL) ' ,
86+ \defined ('SOCKET_EINVAL ' ) ? \SOCKET_EINVAL : 22
87+ );
8588 }
8689
8790 $ this ->loop = $ loop ?: Loop::get ();
@@ -95,7 +98,10 @@ public function __construct($fd, LoopInterface $loop = null)
9598 $ errno = isset ($ m [1 ]) ? (int ) $ m [1 ] : 0 ;
9699 $ errstr = isset ($ m [2 ]) ? $ m [2 ] : $ error ['message ' ];
97100
98- throw new \RuntimeException ('Failed to listen on FD ' . $ fd . ': ' . $ errstr , $ errno );
101+ throw new \RuntimeException (
102+ 'Failed to listen on FD ' . $ fd . ': ' . $ errstr . SocketServer::errconst ($ errno ),
103+ $ errno
104+ );
99105 }
100106
101107 $ meta = \stream_get_meta_data ($ this ->master );
@@ -105,7 +111,10 @@ public function __construct($fd, LoopInterface $loop = null)
105111 $ errno = \defined ('SOCKET_ENOTSOCK ' ) ? \SOCKET_ENOTSOCK : 88 ;
106112 $ errstr = \function_exists ('socket_strerror ' ) ? \socket_strerror ($ errno ) : 'Not a socket ' ;
107113
108- throw new \RuntimeException ('Failed to listen on FD ' . $ fd . ': ' . $ errstr , $ errno );
114+ throw new \RuntimeException (
115+ 'Failed to listen on FD ' . $ fd . ': ' . $ errstr . ' (ENOTSOCK) ' ,
116+ $ errno
117+ );
109118 }
110119
111120 // Socket should not have a peer address if this is a listening socket.
@@ -116,7 +125,10 @@ public function __construct($fd, LoopInterface $loop = null)
116125 $ errno = \defined ('SOCKET_EISCONN ' ) ? \SOCKET_EISCONN : 106 ;
117126 $ errstr = \function_exists ('socket_strerror ' ) ? \socket_strerror ($ errno ) : 'Socket is connected ' ;
118127
119- throw new \RuntimeException ('Failed to listen on FD ' . $ fd . ': ' . $ errstr , $ errno );
128+ throw new \RuntimeException (
129+ 'Failed to listen on FD ' . $ fd . ': ' . $ errstr . ' (EISCONN) ' ,
130+ $ errno
131+ );
120132 }
121133
122134 // Assume this is a Unix domain socket (UDS) when its listening address doesn't parse as a valid URL with a port.
0 commit comments