LinkedDestiny / swoole-doc

swoole文档及入门教程
1.6k stars 733 forks source link

05 client.php写错了! #14

Open wanminny opened 8 years ago

wanminny commented 8 years ago

<?php class Client { private $client; public function __construct() { $this->client = new swoole_client(SWOOLE_SOCK_TCP); } public function connect() { if( !$this->client->connect("127.0.0.1", 9501 , 1) ) { echo "Error: {$fp->errMsg}[{$fp->errCode}]\n"; } $msg_normal = "This is a Msg"; $msg_eof = "This is a Msg\r\n"; $msg_length = pack("N" , strlen($msg_eof) ). $msg_eof; $i = 0; while( $i < 100 ) { $this->client->send( $msg_length ); $i ++; } } } $client = new Client(); $client->connect();