Here is a brief description of what I want to accomplish.
I am developing a peer to peer application using sockets. I want all my communication to be asynchronous. When ever a peer will ask another peer for something, it will send him the request tagged with a unique id. He will also store this information that what should he do with he receives a reply back tagged with id that he just sent. The peer who receives this request will either execute the request or pass it on to one of his peers whom he thinks will be able to execute it. Now the last peer who will actually execute this request will send the response directly to the guy who initiated this request.
There are other design choices available like start a new thread for every request or use call backs with threads, but I want to use simple message passign scheme with sockets.
Is there any good design pattern that I may employ? i.e. send a request, forget about it or in other start doing some jobs and then when I get the response to my request I should know what to do next. I can send this information, i.e. what to do next, embedded in the object or I can store it in a hash table with msg id as the key.
Any good design that you can come up with?