Title: [Socket] Server::listen() is blocking if given a hostname · Issue #181 · reactphp/reactphp · GitHub
Open Graph Title: [Socket] Server::listen() is blocking if given a hostname · Issue #181 · reactphp/reactphp
X Title: [Socket] Server::listen() is blocking if given a hostname · Issue #181 · reactphp/reactphp
Description: Calling Socket\Server::listen($port, $host) with a hostname instead of an IPv4 address is a blocking operation. Example: $server = new Socket\Server($loop); $server->listen(1234, 'example.com'); Giving a hostname will result in resolving...
Open Graph Description: Calling Socket\Server::listen($port, $host) with a hostname instead of an IPv4 address is a blocking operation. Example: $server = new Socket\Server($loop); $server->listen(1234, 'example.com'); Gi...
X Description: Calling Socket\Server::listen($port, $host) with a hostname instead of an IPv4 address is a blocking operation. Example: $server = new Socket\Server($loop); $server->listen(1234, 'example.co...
Opengraph URL: https://github.com/reactphp/reactphp/issues/181
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Socket] Server::listen() is blocking if given a hostname","articleBody":"Calling Socket\\Server::listen($port, $host) with a hostname instead of an IPv4 address is a blocking operation.\n\nExample:\n\n``` php\n$server = new Socket\\Server($loop);\n$server->listen(1234, 'example.com');\n```\n\nGiving a hostname will result in resolving it via DNS (blocking).\n\nPossible solutions include:\n1. Reject hostnames altogether and only accept IP addresses. Easy temporary solution, but listening on hostnames is a convenient feature, think of listening on `localhost:1234`\n2. Accept this as a known limitation and block. Not likely that we want to see something like this in an async library though\n3. Async resolving via React\\Dns component: Requires passing in a Resolver instance somewhere and will have to change the `listen()` method to return a Promise instead. Should be pretty straight forward, but changing the API in such a subtle way is likely going to break existing code\n4. Create new `Socket\\Factory` class that does all the work, accept an optional Resolver instance to resolve any hostnames before passing it to a `listen()` call.\n\nPersonally, I'd go for suggestion 4 as we have a number of outstanding issues with `Socket\\Server` anyway (UNIX sockets, SSL sockets, no IPv6 support, API consistency, etc.). I've implemented a very similar factory for clue/socket-react [here](https://github.com/clue/socket-react/blob/e7c457e7db8424d468d0dc1fc2ae0bcc31dbe2d6/Socket/React/Stream/Factory.php#L100) and [here](https://github.com/clue/socket-react/blob/e7c457e7db8424d468d0dc1fc2ae0bcc31dbe2d6/Socket/React/Datagram/Factory.php#L65) and for clue/socket-raw [here](https://github.com/clue/socket-raw/blob/f687c65b20fe9984b248d151e2eb68482bb840f5/Socket/Raw/Factory.php#L36). It's been working out quite good (feel free to take a look at each projects' examples) and I'd love to see something similar in react.\n\nIn the future this could possibly also allow merging SocketClient and Socket into a single package as they share quite a bit of code and it could allow us to call\n\n``` php\nFactory::createServer('localhost:1234')->then(function (Server $server) { });\nFactory::createClient('localhost:1234')->then(function (Connection $client) {\n $client->end('hello');\n});\n```\n\nThis provides a very consistent API, is very similar to how `stream_socket_server()` and `stream_socket_client()` work and could easily be extended to support IPv6, SSL and UNIX domain sockets.\n","author":{"url":"https://github.com/clue","@type":"Person","name":"clue"},"datePublished":"2013-04-20T10:52:07Z","url":"https://github.com/reactphp/reactphp/issues/181"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:63313fdc-c5cd-a103-c5ad-3ea320773914 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BF5C:EDA7A:1F75C7:29022F:6B00CBAA |
| html-safe-nonce | 0841d9e49b5f23cfccc29d7ae8103920273b83e795728a257f59f0a6d3e9aeef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjVDOkVEQTdBOjFGNzVDNzoyOTAyMkY6NkIwMENCQUEiLCJ2aXNpdG9yX2lkIjoiMzAxMTEzMjY4NjA0MDM1MzcwNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | af966b6cfbfb0f7fe9d7f6220d758af60b475145e8ae40b6529cd09c303eb3dc |
| hovercard-subject-tag | issue:13432621 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/reactphp/reactphp/181/issue_layout |
| twitter:image | https://opengraph.githubassets.com/41dab6aec73058ae6bb690c07630a12cb13ccada8dc9588430756f9f0b5f0219/reactphp/reactphp/issues/181 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/41dab6aec73058ae6bb690c07630a12cb13ccada8dc9588430756f9f0b5f0219/reactphp/reactphp/issues/181 |
| og:image:alt | Calling Socket\Server::listen($port, $host) with a hostname instead of an IPv4 address is a blocking operation. Example: $server = new Socket\Server($loop); $server->listen(1234, 'example.com'); Gi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | clue |
| hostname | github.com |
| expected-hostname | github.com |
| None | 98dc00e171c204462a6f367482a0f8c3c6b5dbca99cd7390e82d2df49ce096e4 |
| turbo-cache-control | no-preview |
| go-import | github.com/reactphp/reactphp git https://github.com/reactphp/reactphp.git |
| octolytics-dimension-user_id | 1696866 |
| octolytics-dimension-user_login | reactphp |
| octolytics-dimension-repository_id | 4287921 |
| octolytics-dimension-repository_nwo | reactphp/reactphp |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 4287921 |
| octolytics-dimension-repository_network_root_nwo | reactphp/reactphp |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ef013399cf0a3c324bea644a685d7c1e0f06b5b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width