Hi,
Im using this sockets library with C++ http://www.alhem.net/Sockets/tutorial/using1a.html
This works in non-blocking event based style mode. So if i do the following:
Then as a result the OnRead() method of mysockclass gets called 3 times whenever a response is sent back from the server.
This asynchronous design is all very nice, but im a little stuck as to how i process the response when it comes in.
Say when i send "command1" i need to process the response in OnRead() with specific regards to what was sent.
So if i send "command1" and the server sends back a string which OnRead() processes how can i tell it was from command1? (there is nothing specific in the server response that can tell me this).
With blocking sockets, i would do something like this:
But how is this approach handled in an asynchronous design?
One idea i did have was having some kind of flag that would signal what i expect to receive and process the data according to that flag.
Thanks for any advice.
Jack
Im using this sockets library with C++ http://www.alhem.net/Sockets/tutorial/using1a.html
This works in non-blocking event based style mode. So if i do the following:
Code:
mysockclass->Send("command1\r\n");
mysockclass->Send("command2\r\n");
mysockclass->Send("command3\r\n");
Then as a result the OnRead() method of mysockclass gets called 3 times whenever a response is sent back from the server.
This asynchronous design is all very nice, but im a little stuck as to how i process the response when it comes in.
Say when i send "command1" i need to process the response in OnRead() with specific regards to what was sent.
So if i send "command1" and the server sends back a string which OnRead() processes how can i tell it was from command1? (there is nothing specific in the server response that can tell me this).
With blocking sockets, i would do something like this:
Code:
Send(string1)
recv() // I would know what to expect in here
send(string2)
recv() // Again i would know what to expect
...
But how is this approach handled in an asynchronous design?
One idea i did have was having some kind of flag that would signal what i expect to receive and process the data according to that flag.
Thanks for any advice.
Jack