• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
cookery

Receive packets in the thread or in game render.

6 posts in this topic

Server sends many packets to one client example 100 packets/one second when client can receive only 40 packets/one second because client is handling packets in render function which reaches 40fps. In some minutes it makes big lag and client can't apply these packets to the game (can not keep up). I can't at the same time receive packets in thread and apply these informations to the game because it makes some problems in client's program and does crashes. I would receive packets in thread (it's much faster than game render function) and apply informations from packets received in thread to the game, but it's some strange method and makes a lot of not needed redirects thread->gameRenderFunction. What can I do with this? How work other multiplayer games, these receive packets in thread and apply them to the game render function? How it looks like?

0

Share this post


Link to post
Share on other sites

There should be nothing stopping you from receiving more than one packet per frame. So a 40fps game should not be limiting you to 40 packets per second.

 

The server sending 100 packets per frame sounds wrong though. It could consolidate multiple game messages into a single packet and save a lot of bandwidth and CPU. Although if you're targeting desktop hardware then this is probably not a significant issue.

 

To receive messages on a thread, you probably just want to have the thread receive the message and just add it into some sort of thread safe queue, so that the main thread can consume the messages at an appropriate time.

2

Share this post


Link to post
Share on other sites

To receive messages on a thread, you probably just want to have the thread receive the message and just add it into some sort of thread safe queue, so that the main thread can consume the messages at an appropriate time.

 

Exactly. I have done some tests. In 10 seconds I can:

 

- receive 390 packets in the game render function

- receive 4000 packets in the thread

 

It's very big difference. 390 packets in 10 seconds its very little and it can make some lags example for 20 players. Server sends to one client 100 packets per second, not per frame, so client can receive only 390 packets in 10 seconds (should receive 1000 packets) which I could process them. My only option is just receive in the thread and make safe queue?

0

Share this post


Link to post
Share on other sites

I meant to say that the server sending 100 packets to a single client in a second is excessive (100 packets per frame would be crazily high). Ideally you should consolidate your messages into fewer packets. e.g. If you're sending positions for 10 entities 10 times per second, then you can package that information up into 10 packets instead of 100.

 

However, I'm still not sure why there would be a limit of one packet receive per frame on the client when you're handling the messages in the render thread. I suspect there's something wrong with your code if you find that's the case.

 

Receiving messages on a worker thread and sticking them into a thread safe queue would be a good approach, but I suspect there's no good reason that receiving messages on the main thread couldn't also be made to work.

0

Share this post


Link to post
Share on other sites

Hm.. I had call to Receiver function 10-50 times per frame in Game Render function and there aren't any lags. Thank you very much for help :)

0

Share this post


Link to post
Share on other sites

C0lumbo is pretty much on track.  Process all messages that have arrived rather than just one, and look at your frequency of messages.

 

I have moved this question to the Networking forum where it belongs.  Check the Forum FAQ and the links it contains, especially Q12 and Q14.

0

Share this post


Link to post
Share on other sites

The packets are already received by the computer and buffered in the kernel. All that your "receive" function does is copy the received data out of the kernel to your application. If you write the code correctly, you should be able to receive hundreds of thousands of packets a second from a single thread (be it main thread or other thread.)

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0