Advertisement

Data transmission intervals at 1/6th second - can this be sped up?

Started by October 30, 2005 03:41 PM
3 comments, last by Roof Top Pew Wee 19 years, 3 months ago
So, first off let me admit openly that I'm pretty new to network programming so forgive my poor vocabulary and (perhaps) silly question. I'm working on some network code to send game information back and forth between two computers. I'm testing my code on two machines both hooked to the same router (so lag is probably not much of an issue here). The code's written in C#, if that matters. I'm creating a socket as follows: new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); And using the Socket's Send method to send information. Everything works fine except that data is not sent very often. Although inefficient, I'm currently sending a float every frame which represents the player's aiming angle. The receiving computer seems to be updating about 5 or 6 times a second. Not horrible, but not great. Sending and listening is done every frame (over 100 times a second), so the information must be buffered somewhere. My guess on the sending side. Is there any way to force flush the information so that it gets sent right away, assuming that this is the problem? Again, I'm kinda new at this so any advice would be great. --Vic--
tcp sockets wait until a buffer is filled before sending information, if you use udp which I would recommend for what your saying it should resolve your issue.
Advertisement
READ THE FAQ!!! I'm expecting that. Guess I just have to turn NoDelay to true.

SetSocketOption( System.Net.Sockets.SocketOptionLevel.Tcp, System.Net.Sockets.SocketOptionName.NoDelay, true);

Sorry for the dumb question.

--Vic--

edit:

Make that

SetSocketOption( System.Net.Sockets.SocketOptionLevel.Tcp, System.Net.Sockets.SocketOptionName.NoDelay, 1);

[Edited by - Roof Top Pew Wee on October 30, 2005 5:56:27 PM]
Quote:
Original post by Roof Top Pew Wee
I'm expecting that. Guess I just have to turn NoDelay to true.

Or use UDP instead... Or just leave it, because later on you're going to send a lot more than a single float with each update anyway, so it won't be a problem then.

You might get a lot of overhead if you use nodelay though.

Good idea, howevever, this particular game uses VERY little bandwidth. Basically the direction you're firing, a firing event, and some state changes. It's a simple puzzle game.

I'll keep that in mind with turning NoDelay off and on.

--Vic--

[Edited by - Roof Top Pew Wee on October 30, 2005 5:07:42 PM]

This topic is closed to new replies.

Advertisement