note 128052 added to sockets.examples

From: Date: Sun, 25 Dec 2022 15:53:18 +0000
Subject: note 128052 added to sockets.examples
Groups: php.notes 
Request: Send a blank email to php-notes+get-220007@lists.php.net to get a copy of this message
Good example from Javier. For using in docker container you can use 0 as an address: $address = '0'; To broadcast a message to all clients, you can use socket_write() for all required clients: ... // Handle Input foreach ($clients as $key => $client) { if (in_array($client, $read)) { ... if ($buf == 'message') { $talkback = "$buf $key\n"; foreach ($clients as $curClient) { socket_write($curClient, $talkback, strlen($talkback)); } continue; } ... } } ... ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.175 (proxied: 188.37.13.243) ---- Manual Page -- https://php.net/manual/en/sockets.examples.php Edit -- https://main.php.net/note/edit/128052 Del: integrated -- https://main.php.net/note/delete/128052/integrated Del: useless -- https://main.php.net/note/delete/128052/useless Del: bad code -- https://main.php.net/note/delete/128052/bad+code Del: spam -- https://main.php.net/note/delete/128052/spam Del: non-english -- https://main.php.net/note/delete/128052/non-english Del: in docs -- https://main.php.net/note/delete/128052/in+docs Del: other reasons-- https://main.php.net/note/delete/128052 Reject -- https://main.php.net/note/reject/128052 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220007) next »