当前位置:网站首页>Small problems in the spoole framework for TCP communication in PHP

Small problems in the spoole framework for TCP communication in PHP

2022-06-23 05:04:00 mayday_ eighty

Colleagues use php swoole Framed tcp Communications But the communication with the external remote server has failed
Just want to use python There is a problem with the data format written by the remote server

# -*- codeing = utf-8 -*-
# @Time : 2022/6/22 10:58
# @Author: CXZ
# @Flie : tcp_client.py
# @Software: PyCharm
import socket
ip ="xx.xx.xx.xx"
port =8080
#ip ="127.0.0.1"
#port =5052
new_socket =socket.socket()# establish socket object 
new_socket.connect((ip,port)) # link 
#new_socket.send("abcde".encode(encoding='utf-8')) # send data   Response data  write  Corresponding server Of read
new_socket.send(b'~\x80\x00\x02\x00\x00\x03RS\x81\x05\x87\x11\x00\x00%\x00\xb7~')
print('11111111')
#back_str = new_socket.recv(port).decode()# End data   Request data  read  Corresponding server Of write
back_str =  new_socket.recv(port)
print(bytes(back_str))
print((back_str.hex()))
new_socket.close()

Forget is in csdn See which brother shared the code ......
My test is OK , It turns out that php The native tcp The interface can also communicate with the remote server normally . But with swoole Does not work . Say something more , As if unity It is used by colleagues api There is also this problem . It seems that primordial is the simplest, roughest and most effective use

原网站

版权声明
本文为[mayday_ eighty]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206222342048442.html