1 Unstar Star 0 Fork 0

天蝎儿 / swoole多进程行务PHP

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Nothing here. spread retract

Clone or download
Client.php 786 Bytes
Copy Edit Web IDE Raw Blame History
ME倒霉怪 authored 2020-07-01 13:02 . 初始化
<?php
/*
* 客户端投递任务
* */
for($i=0;$i<1;$i++) {
$socket=new \Co\Socket(AF_INET,SOCK_STREAM,0);
go(function () use ($socket, $i) {
$id = $i+1;
$rebe = 10000;
$socket->connect('127.0.0.1', 9515);
while ($rebe > 0) {
// co::sleep(0.1);
$random = random_int(1, 10);
$message = str_repeat('hello=>' . $rebe . '&', $random);
$message = json_encode(['id' => $id,'number'=>$rebe, 'message' => $message]);
$messageByte = packs($message);
$socket->send($messageByte);
$rebe--;
//co::sleep(0.1);
}
});
}
function packs($message){
$fooLenn = pack("N", strlen($message));
$package = $fooLenn . $message;
return $package;
}

Comment ( 0 )

Sign in for post a comment

PHP
1
https://gitee.com/kelley0827/swote_multi_process_operation.git
git@gitee.com:kelley0827/swote_multi_process_operation.git
kelley0827
swote_multi_process_operation
swoole多进程行务
master

Search

132457 8cb2edc1 1899542 131848 70c8d3a4 1899542