Python Socket 使用 Struct.pack 组包问题
伊谢尔伦
伊谢尔伦 2017-04-17 17:08:29
0
0
746

问题描述

数据包具体的内容

Java消息体实现代码`

public Message(String content) {
    length = new int[]{calcMessageLength(content), 0x00, 0x00, 0x00};
    code = new int[]{calcMessageLength(content), 0x00, 0x00, 0x00};
    magic = new int[]{0xb1, 0x02, 0x00, 0x00};
    this.content = content;
    end = new int[]{0x00};
}

`

发出的消息内容

Message{length=[173, 0, 0, 0], code=[173, 0, 0, 0], magic=[177, 2, 0, 0], content='type@=loginreq/username@=/ct@=0/password@=/roomid@=321358/devid@=B609634DCCFC4DD48BF085BB35B7CF97/rt@=1453874133/vk@=1e1806220f06b5402cab6486e99e42da/ver@=20150929/', end=[0]}

问题

如何使用 Python 的 struct.pack 来完成相同的功能?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

répondre à tous(0)
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!