Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to come up with a design to efficiently send a tree data structure (each node can have more than 2 branches) to a socket/different process etc. There seems to be a cap on how much data can be sent in one message (1500 Bytes). The tree data structure can get very big (into 100s of nodes may be). I initially started off by thinking of having a linear data structure like an array (example: [root, number of top nodes, node1, node2, node3 ..., number of next level node, node1, node2 , node3 and so on] and serializing this and sending it to the other process thorough a socket.

I am trying to figure out the most efficient way to do this given the constraints ( large tree, how to split given the limit on number of bytes per message)

I am yet to explore if I should use Protobuf, XDR , JSON for interprocess communication

What I have tried:

Just in the design phase. Learning how to go about this
Posted
Updated 10-Aug-23 4:10am
v3
Comments
[no name] 10-Aug-23 10:26am    
XML and JSON can represent tree structures. Anything else, and it all gets too "abstract".
Mike Hankey 10-Aug-23 14:05pm    
Have you thought about converting to array, sending a manageable packet(s) at a time and convert back on the other end?
Rick York 10-Aug-23 14:25pm    
Keep in mind that with TCP/IP there really ISN'T a limit on number of bytes per message. There is a limit on the number of bytes in a normally-sized pack of about 1500 bytes but a TCP/IP message larger than that will be split between multiple packets and the protocol will insure that they are all received in order. Many NICs and switches support what are called "jumbo frames" which can range between 5 and 15KB. All equipment between sender and receiver must support jumbo frames for you to use them. My point is I wouldn't worry too much about the frame size limit unless you are also writing the protocol handling code and have to deal directly with that. A robust socket handling library should be able handle that kind of thing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900