0

I am using stream_socket_client to connect to the socket server. Using the fwrite() method, I write data there. Here is a sample code:

$localsocket = 'tcp://' . Yii::$app->params['socket.server'] . ':4002';
$message = [
    'message' => $action,
    'data' => $data
];
$instance = stream_socket_client($localsocket);
fwrite($instance, Json::encode(['user' => $token, 'message' => $message]) . "\r\n");

When the tape is not very large - everything works well. but when the tape is larger (an array of data encoded in json) - the server accepts the trimmed tape. at the same time, it cuts differently each time.

I did not find documentation on the limitation. could it be that fwrite() doesn't have time to write the data?

Diefair
  • 153
  • 1
  • 10

0 Answers0