Original Post
Hello, I have a rather straightforward question regarding the use of a separate thread for networking in the client of the multiplayer action game I am currently programming. My apologies if this is a repeated question, but the search feature is not working correctly on my machine (page half-loads with one to three listed topics) and those results that I did manage to find were irrelevant. I have been coding a networking layer built atop HawkNL that provides such features as automatic pinging and connection management, automatic synchronization of timers between remote hosts and semi packet reliability (guaranteed to arrive but not in order). The time-sensitive features such as clock syncing work as one would expect when I run bare non-graphical test programs. The times recorded and used are accurate because the program loop (networking) runs at least once a millisecond (usually around five to six times). However, if my client runs at seventy frames per second (rendering graphics etc), then the networking loop will only execute once every fifteen milliseconds or so (single threaded). Obviously when establishing pings and syncing times this is not ok at all. Having no real experience with multithreaded applications, I ask: is multithreading the answer here? If I run the networking layer in a separate thread, record any application-specific packets received and pass them to the main game thread for processing once every rendering frame, will my network code execute as fast as it possible can over and over again (at least once a ms for best accuracy)? If so, then how can any multiplayer action games survive within a single thread? Thanks for any help, Jackson Allan