PHP Classes

File: src/examples/receiver.php

Recommend this page to a friend!
  Classes of walid laggoune  >  QPHP  >  src/examples/receiver.php  >  Download  
File: src/examples/receiver.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: QPHP
Exchange messages with a queue server using Swoole
Author: By
Last change:
Date: 6 months ago
Size: 640 bytes
 

Contents

Class file image Download
<?php

$address
= '0.0.0.0';
$port = 15674;

if ((
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
    echo
"socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
}

if (
socket_connect($sock, $address, $port) === false) {
    echo
"socket_connect() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
}
// listen for message in channel "public"
socket_write($sock, json_encode(["header" => "JOIN_CHANNEL", "payload" => ["CHANNEL_NAME" => "public"]])." \r\n");

$i = 0;
while(
$out = socket_read($sock, 5042, PHP_NORMAL_READ)) {
    echo
$i."\n";
   
var_dump($out);
   
$i++;
}

For more information send a message to info at phpclasses dot org.