You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$socket->on('connection', function ($conn)
{
$conn->write("Hello there!\n");
$conn->on('data', function ($data) use ($conn) {
$conn->write("I have received a data!\n");
$conn->close();
});
});
The problem is I only receive "Hello there" string, but not "I have received a data!\n". I am not receiving second string even with sleep(5) or something before $conn->close() line. Is this a bug or I am doing something wrong?
close immediately closes the socket. Being an asynchronous environment that could happen before the write happens. Instead, use $conn->end(). That will close the connection after the write buffer has been drained.
Hi!
I have a following code
The problem is I only receive "Hello there" string, but not "I have received a data!\n". I am not receiving second string even with sleep(5) or something before
$conn->close()
line. Is this a bug or I am doing something wrong?Thank you in advance.
PS
comoser:
php -v:
The text was updated successfully, but these errors were encountered: