-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can you please tell me how the client code in php will look like? #892
Comments
Change
to
|
I changed the value tcp to text as you suggested. Now I'm trying to get data using the php client below, but I'm getting an error client code
I will be very grateful if you help me with this |
client codes
|
Yes, this code works well for sending data, but can you please advise something about receiving data from the server using php? |
If you want to use workerman as client , the codes like this. <?php
require_once __DIR__ . '/vendor/autoload.php';
use Workerman\Connection\AsyncTcpConnection;
use Workerman\Connection\TcpConnection;
use Workerman\Worker;
$worker = new Worker();
$worker->onWorkerStart = function($worker)
{
$server_address = 'text://localhost:1234';
$connection = new AsyncTcpConnection($server_address);
$connection->onMessage = function ($connection, $data) {
echo "from server: $data\n";
};
$connection->onClose = function ($connection) {
echo "connection closed\n";
};
$connection->connect();
$stdin = new TcpConnection(STDIN);
$stdin->onMessage = function($stdin, $message) use ($connection) {
echo "send $message\n";
$connection->send($message);
};
};
Worker::runAll(); |
Can you please tell me how the client code in php will look like? The client must be able to send data to the server and receive data from other clients
my server
example of a client that sends data but does not receive it
an example on js
The text was updated successfully, but these errors were encountered: