Floppe
18th March 2009, 07:33
Hello,
I'm trying to build a class MySocket which I think would be best if it starts a thread for incoming data and stores that data in a buffer which should be shared with the parent thread. All other functions are outside this worker thread.
Basic example would be a ping function. This function sends a ping to the server and waits for an answer and timeouts if no answer is received. This answer is parsed from the buffer. So in short, incoming data should be feed to the buffer while this function waits (which could take 10 seconds over laggish GPRS).
How should I build this?
Or are there any better ideas to accomplish this?
If main thread declares MySocket and connects to server, can worker threads use this same connection?
// Floppe
I'm trying to build a class MySocket which I think would be best if it starts a thread for incoming data and stores that data in a buffer which should be shared with the parent thread. All other functions are outside this worker thread.
Basic example would be a ping function. This function sends a ping to the server and waits for an answer and timeouts if no answer is received. This answer is parsed from the buffer. So in short, incoming data should be feed to the buffer while this function waits (which could take 10 seconds over laggish GPRS).
How should I build this?
Or are there any better ideas to accomplish this?
If main thread declares MySocket and connects to server, can worker threads use this same connection?
// Floppe