首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python send会不会丢掉数据

2012-09-17 
python send会不会丢失数据我这边用python写一个发送端,发送的结构体是class regadd_struct(Structure):_f

python send会不会丢失数据
我这边用python写一个发送端,发送的结构体是
class regadd_struct(Structure):
  _fields_=[
  ("command",c_uint),
  ("result",c_uint),
  ("keypath",c_char* 200),
  ("valnmae",c_char* 56),
  ("type",c_uint),
  ("datasize",c_uint),
  ("data",regdatatype),
  ]
对方用C写的接收端,但是对方接收不到我的valnmae变量,接收到是0
我看我这边send这个结构体时没问题,他那边接收的也确实没问题,但是就是少了这个值,请教下怎么回事

[解决办法]
发送时需要将内存数据串行化,看看串行化后的结果对不?
[解决办法]
可以用 wireshark 线路抓包来确认发送还是接收的问题
[解决办法]
看看keypath是不是也是0
[解决办法]
_pack_ 
An optional small integer that allows to override the alignment of structure fields in the instance. _pack_ must already be defined when _fields_ is assigned, otherwise it will have no effect.


主动在两端强制对齐到统一的字节, 比如1,2,4,8之一。

热点排行