当前位置:网站首页>关于php里tcp通讯用swoole框架出现的小问题
关于php里tcp通讯用swoole框架出现的小问题
2022-06-23 03:50:00 【mayday_80】
同事用php swoole框架搭的tcp通讯 但是一直跟外面的远程服务器通讯失败
就想着用python跟外面的远程服务器通讯测试是不是他写的数据格式是有问题的
# -*- 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()#创建socket对象
new_socket.connect((ip,port)) #链接
#new_socket.send("abcde".encode(encoding='utf-8')) #发送数据 回应数据 write 对应server的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()#结束数据 请求数据 read 对应server的write
back_str = new_socket.recv(port)
print(bytes(back_str))
print((back_str.hex()))
new_socket.close()
忘记是在csdn看的哪个兄弟分享的代码了。。。。。。
我的测试是没有问题的,最后发现用php的原生tcp接口也是能正常跟远程服务器通讯的。但是用swoole确实不行。多嘴一下,好像unity里面同事用的api也是有这个问题。好像原生才是最简单粗暴有效的使用
边栏推荐
- 制造型企业开发的SRM供应商管理系统特点是什么
- 麦肯锡:2021年量子计算市场投资增长强劲,人才缺口扩大
- PTA:7-85 数据的间距问题(重载+函数模板)
- PTA:7-67 友元很简单2016final
- leetcode 91. Decode ways (medium)
- 在线JSON转CSharp(C#)Class工具
- Pytorch---使用Pytorch的预训练模型实现四种天气分类问题
- Audio and video development journey (63) - animation and rendering of Lottie source code analysis
- Leetcode 1208. Make strings as equal as possible
- [learn FPGA programming from scratch -40]: Advanced - Design - competition and risk
猜你喜欢

Pytorch---使用Pytorch的预训练模型实现四种天气分类问题

Deploying Apache pulsar on kubesphere

Please use the NLTK Downloader to obtain the resource

JD cloud distributed database stardb won the "stability practice pioneer" of China Academy of information technology

国家药品不良反应监测中心 ADR 电子传输EDI解决方案

LabVIEW在同一表中同时显示十六进制字符和普通字符

How does flutter achieve different zoom animation effects

【一起上水硕系列】Day Three - preview4

论文阅读_关系抽取_CASREL

Particle animation background login page particles js
随机推荐
深度学习 简介
一篇文章学会er图绘制
Cocos学习日记1——节点
PTA: Simulation Implementation of 7-86 set (function template)
Pta:6-33 student ranking table (destructor)
[从零开始学习FPGA编程-40]:进阶篇 - 设计-竞争与风险Risk或冒险
Online text filter less than specified length tool
Introduction and use of MySQL view
PTA:7-67 友元很简单2016final
LabVIEW displays both hexadecimal and normal characters in the same table
Leetcode 1208. Make strings as equal as possible
【二叉树进阶】AVLTree - 平衡二叉搜索树
[advanced binary tree] AVLTree - balanced binary search tree
What are the characteristics of SRM supplier management system developed by manufacturing enterprises
PTA:7-87 集合的模拟实现(类模板)
x64dbg 基本使用技巧
Pta:6-73 function call
PTA:7-85 数据的间距问题(重载+函数模板)
P1363 幻象迷宫(dfs)
Qt 及QT VS Tools插件官方下载及安装