Network Message Systems
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===---
----THE END----
---===xxxx===---
By the way, the std::list is a list of pointers to cMsg classes.
---===xxxx===---
----THE END----
---===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
That''s my input anyway.
Steve ''Sly'' Williams Code Monkey Krome Studios
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement