Heim >Backend-Entwicklung >PHP-Tutorial > PHP websocket与C服务端通信的有关问题
PHP websocket与C服务端通信的问题
//$send_format: a4lllllalllllaala*a4<br /> $send_format = "a4LLLLLaLLLLLaaLa".$packet_content_length."a4";<br /> $bin_pack = pack($send_format,<br /> $begin_tag,$body_tail_length,$all_packet_number,$envoy_id,$recognition_code,<br /> $packet_id,$packet_request_type,$packet_body_length,<br /> $packet_taskNO,$packet_middelpacketNo,$packet_minitasksequenceNo,$packet_specialkey,<br /> $packet_trans_type,$packet_content_format,$packet_content_length,$packet_content,<br /> $end_tag);<br /> //----pack----------------------------------<br /> //--------------send---------------------------<br /> $waited_socket_write_length = BEGIN_TAG_B + BODY_TAIL_LENGTH_B + ALL_PACKET_NUMBER_B + ENVOY_ID_B + RECOGNITION_CODE_B + $body_tail_length;//20+$body_tail_length;<br /> $actually_socket_write_length = @socket_write($socket,$bin_pack,$waited_socket_write_length);<br /> if($actually_socket_write_length != $waited_socket_write_length)<br /> {<br /> socket_close($socket);<br /> $result = array('EnglishToChineseReturn' => SOCKET_WRITE_ERROR);<br /> return $result;<br /> }