本文介绍了(Python)通过网络发送结构化数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个聊天应用程序,该应用程序支持文本消息传递,组消息传递,文件传输(例如netmeeting).当我通过TCP套接字发送它时,我看到数据不是结构化的,所有数据都通过TCP以字符串形式发送.我想以结构化的方式发送它,并使用一些标头,例如name:,ip:,data:,data_type_flag :(文件或文本消息)等...一个stackoverflow成员告诉我使用TELEPATHY,但我无法获得一个简单的方法教程了解.如何通过套接字发送结构化数据?或可以给我推荐一个很好的教程来正确实现心灵感应.我想通过网络作为对等而不是专用服务器进行通信..谢谢

i want to build a chat application which supports text messaging, group messaging, file transfer(like netmeeting). when i send it over TCP socket i saw that data is not structured all the data send as string over TCP. I want to send it in a structured way with few headers like name:,ip:,data:,data_type_flag:(file or text message) etc... one stackoverflow member told me to use TELEPATHY but i can't get a simple tutorial to understand. how can i send structured data over socket? or can any one suggest me a good tutorial to implement telepathy properly. i want to communicate over network as peer-to-peer rather than dedicated server.. Thanks

推荐答案

尝试 Google协议缓冲区 apache节俭.有许多使用它们的示例.

Try google protcol buffers or apache thrift. There are many examples for how to use them.

关于您对点对点"的评论,请意识到即使在点对点中,也有一个对等点始终充当服务器(有时两者都是).

As for your comment about "peer to peer", please realize that even in peer-to-peer one of the peers is always acting as a server (sometimes both are).

这篇关于(Python)通过网络发送结构化数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 03:49