您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP 与 C 通信 .

2024/6/5 3:01:06发布42次查看
php 与 c 通信 求助..........
功能:修改用户账户
服务器端是 c语言 udp协议
ip:8.14.26.53
port:34556
客户端是 php
如何发包过去?
服务器提供的协议:
1、包头
typedef struct
{
unsigned short ushlength; //包长度
unsigned int usequence; //请求包seq  
unsigned short ushcmd; //命令(0x2用户修改密)
char cresult;  
}pkghead;
2、修改密码
typedef struct
{
char cstx; //0x2
pkghead sthead;  
unsigned int uin; //用户id
unsigned short ushusernamelength;//用户名长度
char susername[]; //用户名buf
unsigned short ushpasswdlength; //密码长度
char spasswd[]; //密码buf
char cetx; //0x3
}reqpasswdresetpkg;
typedef struct
{
char cstx;
pkghead sthead;
char estx;
} resppasswdresetpkg;
------解决方案--------------------
应该是socket,去查查资料吧
------解决方案--------------------
pack将每一个数值打包到大端, 拼为字节流写出去就行了。
c服务端注意#progma pack(1)保证结构体无填充, 否则php这端处理起来还是麻烦了点.
建议协议尽量走json/xml, 对于c还是php还是其他任何语言都是有利的, 现在不流行二进制协议了.
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product