{"id":37014309,"url":"https://github.com/webbeta/socket","last_synced_at":"2026-01-14T01:25:07.225Z","repository":{"id":19204593,"uuid":"22438186","full_name":"webbeta/socket","owner":"webbeta","description":"Asynchronous socket server","archived":false,"fork":true,"pushed_at":"2014-07-31T16:32:12.000Z","size":162,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-27T16:46:28.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"reactphp/socket","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webbeta.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-30T17:39:29.000Z","updated_at":"2014-07-30T18:59:04.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/webbeta/socket","commit_stats":null,"previous_names":["webetes/socket"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/webbeta/socket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbeta%2Fsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbeta%2Fsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbeta%2Fsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbeta%2Fsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webbeta","download_url":"https://codeload.github.com/webbeta/socket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbeta%2Fsocket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407696,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T01:25:06.570Z","updated_at":"2026-01-14T01:25:07.209Z","avatar_url":"https://github.com/webbeta.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Socket Component\n\n[![Build Status](https://secure.travis-ci.org/reactphp/socket.png?branch=master)](http://travis-ci.org/reactphp/socket)\n\nLibrary for building an evented socket server.\n\nThe socket component provides a more usable interface for a socket-layer\nserver or client based on the `EventLoop` and `Stream` components.\n\n## Server\n\nThe server can listen on a port and will emit a `connection` event whenever a\nclient connects.\n\n## Connection\n\nThe connection is a readable and writable stream. It can be used in a server\nor in a client context.\n\n## Usage\n\nHere is a server that closes the connection if you send it anything.\n```php\n    $loop = React\\EventLoop\\Factory::create();\n\n    $socket = new React\\Socket\\Server($loop);\n    $socket-\u003eon('connection', function ($conn) {\n        $conn-\u003ewrite(\"Hello there!\\n\");\n        $conn-\u003ewrite(\"Welcome to this amazing server!\\n\");\n        $conn-\u003ewrite(\"Here's a tip: don't say anything.\\n\");\n\n        $conn-\u003eon('data', function ($data) use ($conn) {\n            $conn-\u003eclose();\n        });\n    });\n    $socket-\u003elisten(1337);\n\n    $loop-\u003erun();\n```    \nYou can change the host the socket is listening on through a second parameter \nprovided to the listen method:\n```php\n    $socket-\u003elisten(1337, '192.168.0.1');\n```\nHere's a client that outputs the output of said server and then attempts to\nsend it a string.\n```php\n    $loop = React\\EventLoop\\Factory::create();\n\n    $client = stream_socket_client('tcp://127.0.0.1:1337');\n    $conn = new React\\Socket\\Connection($client, $loop);\n    $conn-\u003epipe(new React\\Stream\\Stream(STDOUT, $loop));\n    $conn-\u003ewrite(\"Hello World!\\n\");\n\n    $loop-\u003erun();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebbeta%2Fsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebbeta%2Fsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebbeta%2Fsocket/lists"}