Home > PHP Framework > Swoole > swoole method to get message sending failure error

swoole method to get message sending failure error

Release: 2019-12-24 16:23:25
Original
2717 people have browsed it

swoole method to get message sending failure error

Send data to the client, function prototype:

bool Server->send(mixed $fd, string $data, int $serverSocket = -1);
Copy after login

The sending process is asynchronous, the bottom layer will automatically listen and write, and gradually send the data to the client

Parameters

$fd, the client’s file descriptor

$data, the data sent, the TCP protocol must not exceed 2M, buffer_output_size can be modified to change the maximum packet length allowed to be sent

$serverSocket, this parameter is required when sending data to the Unix Socket DGRAM peer. The TCP client does not need to fill in

Return value

If the sending is successful, true will be returned

Failure to send will return false. Call the $server->getLastError() method to get the failure error code

Server->getLastError

Get the latest Error code for an operation error. Business code can execute different logic based on error code types.

function Server->getLastError()
Copy after login

Returns an integer numeric error code

Send failure error

1001 The connection has been closed by the server, this error occurs Generally, $serv->close() has been executed in the code to close a certain connection, but $serv->send() is still called to send data to this connection.

1002 The connection has been closed by the client. The Socket has been closed and data cannot be sent to the peer

1003 Close is being executed, $serv->send() must not be used in the onClose callback function

1004 The connection has been closed

1005 The connection does not exist, and the incoming $fd may be wrong.

1007 Timeout data is received. After TCP closes the connection, some data may remain in the pipe buffer, and this part of the data will be Discard

1008 The send buffer is full and the send operation cannot be performed. This error indicates that the peer of this connection cannot receive data in time, causing the send buffer to be full

1202 The data sent exceeds server->buffer_output_size setting

Recommended learning: swoole video tutorial

The above is the detailed content of swoole method to get message sending failure error. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template