reactphp / socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP.
https://reactphp.org/socket/
MIT License
1.2k stars 156 forks source link

Improve error messages for failed TCP/IP connections with errno/errstr #265

Closed clue closed 3 years ago

clue commented 3 years ago

This changeset improves the error messages for failed TCP/IP connections to include the appropriate errno/errstr. Whereas it would previously report a generic "Connection refused" error, it will now report the actual underlying error condition, such as this:

$ telnet 192.168.0.1 8080
Trying 192.168.0.1...
telnet: Unable to connect to remote host: Network is unreachable
$ php examples/11-http-client.php 192.168.0.1
RuntimeException: Connection to tcp://192.168.0.1:80 failed: Network is unreachable in …/TcpConnector.php:115

Builds on top of #171, https://github.com/reactphp/dns/pull/171, https://github.com/reactphp/dns/pull/172 and others