Hi all,
I'm writing a game with multiplayer and networking, and I was wondering what is the best way to receive messages sent from a server.
Currently I'm using the main thread for the game, and creating another thread for a network loop which blocks with #gets() and interprets the results, but this seems to react very slowly to new information sent from the server and the multiplayer aspect is very laggy; because the game I'm making is effectively a MOBA, this is unacceptable and game-breaking. Is there a better way of doing this? I know non-blocking IO would probably be better already, but I don't understand how non-blocking IO works, so if anyone could enlighten me as to how that works, that'd be much appreciated also.
I'm writing a game with multiplayer and networking, and I was wondering what is the best way to receive messages sent from a server.
Currently I'm using the main thread for the game, and creating another thread for a network loop which blocks with #gets() and interprets the results, but this seems to react very slowly to new information sent from the server and the multiplayer aspect is very laggy; because the game I'm making is effectively a MOBA, this is unacceptable and game-breaking. Is there a better way of doing this? I know non-blocking IO would probably be better already, but I don't understand how non-blocking IO works, so if anyone could enlighten me as to how that works, that'd be much appreciated also.