Original Post
[font=arial, verdana, tahoma, sans-serif][size=2]blah[/font]
Quote:
Original post by Kada2k6
This is something I have been thinking about for a while.....
Let's say I've written a server that distributes the current game map when a client connects. This map could be pretty big, maybe it's several megabytes (just as an example). In this case I've written a sort of graphical MUD server/client.
I have sort of figured out that taking this file and just send() it to the client in one call is not very good, and somehow not realistic. If the file was 70 mb, for example, would one send() even do anything? Would it crash?
I'm thinking there needs to be some kind of send buffer. When I want something to be sent to a client, I should put it in a buffer first, and then send() small portions of that buffer over a period of time until the buffer is empty again.
But that leads to some questions from my side:
1) Is this right?
2) How much (data in bytes) should be sent with each send() call?
3) How long should I wait until I do the next send?
4) Surely these values would differ depending on the client's connection speed?
5) Should I make the client acknowledge that data has been received before the server sends more from the buffer?
6) I do not need to do this sort of things when sending stuff like player coordinates, monster attack data, object information etc, etc. So how can I tell when and when not to do the above?
Oh, I almost forgot: I'm using TCP (and I will NOT switch to UDP!! ;-))).
Quote:
I assume I should just use the return value of send() then, to find out how much data was sent and how much to remove from the buffer until next call. The kernel will take care of the rest....?
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more