0

So i have a simple tcp client/server setup that sends objects back and forth and it works all good.

But let's say i now want to make a call and ask the server for a special set of lets say "products" and i need to know what "answer" of the incoming messages is the one i specially asked for.

Since the loop that receives messages just checks what type they have and react to it it's hard to say "this message is the one you asked for".

Example:
- Button is clicked
- Message is send to the server
- A few other messages arrive why i wait for the answer
- The right message arrives <- How to know its the "right" one?
- Call the function that i want to
- Update something in my form

Hope it's clear what i meant.

4

2 Answers 2

1

I'd recommend to design your messaging as followed:

  1. use serializable objects (XmlSerializer) as shown here
  2. this object should have two "main" properties: the payload itself and an identifier to get "what kind of message this is", and maybe add some requestId property (to know that this message is for you, if you are listening to a broadcasting service)
1

You can use the WCF framework to process requests, it handles the serialization & message parsing over HTTP/TCP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.