no ideas on programming high speed internet game...

Started by
6 comments, last by Danil 20 years, 6 months ago
Well, i''m new in game programming so i''ll try to explain my problem how it is. I''am trying to make internet multiplayer game on the principles of old "asteroids". And I do not know how to organize server-client information flow. You see, it supposed that server makes 20 cycles per second. If i try to send info to client each cycle all works well on single machine, but problems appear using dialup or lan connections. And the problem is not in very hight info transfer rate(it s about 1kbyte per second). It appears that info packets that are supposed to be send and recieved 20 times per second actually are transmitted 3-4 times per seckond in bundles of 5-7 packets). How to solve this problem or are there any good ideas how to organize information exchange between server and client? I use TCP. PS It seems that all works well under Linux but the described problem appears when client works under Windows. PSS Is it ok if i use each info packet from server to start game cycle on client, or it would be better to make them more independent? Thank you very much!!
Advertisement
have you tried to disable nagel''s algorithm?
(TCPNODELAY socket option)
No i havn''t . Coud you possibly explain what is that algoritm. How to change socket options while programing sockets on Java?

Thank you!!!
nagel''s algoritm buffers your outgoing data into a larger packet.
eg. if you send a string by outputting each byte individually tcp automatically clamps them together into a single packet.
dunno much about java but a little googleing revealed the following function: Socket.setTcpNoDelay(boolean).
just make sure that you do the buffering yourself instead, otherwise you''ll get alot of overhead from packet headers.
Thank you very much,
Just one more question: (maybe for someone who knows java well) I collect info to send to an array and then write this array to output stream(related to socket) (using function
write(byte[])) ) . Will it be delivered using one tcp header, or maybe it will use one header per byte or else...?
And one more
Is that buffering(nagel''s algorithm) used on senders and recievers sides or only on sender?
sending an array at a time should work fine, and the buffering is only done by the sender. so just call setTcpNoDelay(true) when you create socket you shouldn''t have to worry about it again.

any chance i could test the game, i''ll send you mine in return
Thank you very much!!
I''ve already tested it with setTcpNoDelay and it works wery fine. All is smooth even with my modem.

When i''ll have any playable version i''ll support you with it(if i''ll get any coordinates)

This topic is closed to new replies.

Advertisement