When a swoole client receives a message from the server, the two are merged into one.

the following is the log of the client on the server

ConfigInit demo ... 
config server judge 
ConfigInit -> init 
get_swoole_client 
pms_config:9502 
ConfigInit -> init end 
Receive: s:22:"!";
 
Receive: s:6:"wocao!";
 
ConfigInit demo ... 
config server judge 
ConfigInit -> init 
get_swoole_client 
pms_config:9502 
ConfigInit -> init end 
Receive: s:22:"!";
s:6:"wocao!";
 
ConfigInit demo ... 
config server judge 
ConfigInit -> init 
get_swoole_client 
pms_config:9502 
ConfigInit -> init end 
Receive: s:22:"!";
s:6:"wocao!";
 
ConfigInit demo ... 
config server judge 
ConfigInit -> init 
get_swoole_client 
pms_config:9502 
ConfigInit -> init end 
Receive: s:22:"!";
 
Receive: s:6:"wocao!";

Receive is the callback function received. The code is as follows:

/**
     * 
     * @param \swoole_client $cli
     * @param $data
     */
    public function receive(\swoole_client $cli, $data)
    {
        echo "Receive: $data \n";

    }

the server keeps sending serialized "illegal controller" and "wocao" to the client twice (an interval of 1 second). Sometimes the client receives it separately, sometimes it merges it together. What if the server sends two serialized "illegal controllers" and "illegal controllers" to the client? Can"t receive it together, is there any way to handle the callback!
solve!
the above code is used for the communication between two service, the reference of swoole: https://wiki.swoole.com/wiki/.

.
Feb.27,2021

set your own protocol


has not used swoole, but this looks like a sticky package, you can turn off the Nagle algorithm to try, TCP_NODELAY.
or the receiver processes at the application layer

Menu