Reputation: 3350
I'm writing an application using python sockets and threads. What's the best way to delegate the data after it's transmitted? My first idea was to use different sockets for different kinds of threads, but thought that might not be a good idea for some reason. So now I'm adding an identifying string to every transmission, which the server/client then uses to decide which queue the data should be added to.
My question is, what is the best technique?
It's important to note that for my application it's critical that some variables get synchronized across all clients on every iteration of the main loop.
Upvotes: 2
Views: 262
Reputation: 648
The easiest way to do this is as you described. For a project I had to do that involved networking we determined beforehand a suitable "packet" structure and used that to build and deal with data on both ends.
Ours, for example, was something like
COMMAND || SENDER || DATA_ASSOCIATED_WITH_COMMAND
So when we received the data on either the client or server side we were able to break it down using the delimiter.
EDIT: This may not be the best way, it's probably not by a long shot, but it's fairly basic and easy to implement
Upvotes: 2