Network Message Systems

Started by
2 comments, last by xSuiCidEx 22 years, 11 months ago
I was wondering how everyone has their message queue setup with winsock tcp sockets, or if you even use a message queue. I''m using a std::list to hold all the messages and I use new to allocate messages then i add them to the list. Each player has 2 of these message queues. One for out messages and one for in messages. Then, every cycle in the game I check if there''s any messages in the queues. If there is, then they get sent or received depending on the queue they are in. After the message is sent or received, I erase the message from the list and use delete to deallocate the memory for the message. Does this seem like a logical way to do it? How do you all do it? How do commercial games do it?
---===xxxx===---
----THE END----
---===xxxx===---
Advertisement
By the way, the std::list is a list of pointers to cMsg classes.
---===xxxx===---
----THE END----
---===xxxx===---
anyone? maybe davidrm? =)
---===xxxx===---
----THE END----
---===xxxx===---
I would suggest using a fixed size buffer. Allocate the buffers at program startup once using new and delete them at the end using delete. Then treat them like arrays. Do some testing to see how big the queues get during a busy game and then use that as a maximum size for the buffer. This will save potentially hundreds of thousands of calls to new and delete during a typical game session.

That''s my input anyway.


Steve ''Sly'' Williams  Code Monkey  Krome Studios
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers

This topic is closed to new replies.

Advertisement