|
-
Jan 4th, 2010, 06:13 PM
#1
Thread Starter
Addicted Member
Client/Server application: networking issues design
Hi,
I'm developing a multiplayer game. I'm writing both client and server application.
Client applications need to perform these two tasks:
- Receive messages from Server
- Send requests and read responses from the server right after
The first one is to be able to read events notified from the server. While the second one is a little more complex: it requires a Send() call, but the server in the other side will answer this request at the moment it receives it. And client, depending on the answer from the server, will send a request again and the loop can continue. So, basically, in the client I need a code like the following one:
Code:
//Code to send requests and read responses from the server
ServerSocket.Send(request);
response = ServerSocket.Receive();
if(response is type X)
{
ServerSocket.Send(newrequest);
response = ServerSocket.Receive();
}
but I also need a code, running in a parallel thread, like this:
Code:
//Code to read events from the server
while(Application is running)
{
event = ServerSocket.Receive();
//Act depending on the event
}
Is possible to do it using just one socket?. If it's not, what would be the best approach?
Regards.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|