Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Disable Nagling
#1
Introcution
When adding Verrigans packet buffer to your game: viewtopic.php?f=69&t=894
You will have 2 buffers working on the game, since winsock has it's own inbuilt packet buffer called nagling. Each taking around 100ms-200ms I believe, now we want to get rid of the nagling buffer and only have the buffer constructed for ms games.

And in case you add the buffer now, and already have IOCP, you need to go through my other tutorial to make it work for IOCP: viewtopic.php?f=69&t=1016

Do not turn of nagling without having the packet buffer added!

Client Side
Find this:
Code:
With frmMirage.Socket
        .Close
        .Connect
    End With
Under that, add:
Code:
Call setsockopt(frmMirage.Socket.SocketHandle, IPPROTO_TCP, TCP_NODELAY, 1, 4)
Now, in any of your modules, add:
Code:
Public Const TCP_NODELAY = &H1&
Public Const IPPROTO_TCP = 6
Public Declare Function setsockopt Lib "WSOCK32.DLL" (ByVal s As Long, ByVal Level As Long, ByVal optname As Long, optval As Any, ByVal optlen As Long) As Long

And that should be it! This will probably decrease your ping a little.
Reply
#2
Is this OS specific? On two XP SP2 boxes, there is no entry point found in that DLL.
Reply
#3
Same with a Vista system.
Reply
#4
It should work on XP. Vista always have problems so that wouldn't surprise me. I don't know why it wouldn't work for you guys.
Reply
#5
Worked for me on Vista.

But note Vista also has a registry that limits your half open connections for things like games/P2P networks.
Reply
#6
Good luck ever having a game server that would require more than 10 half-open connections.

Btw, its also part of XP (SP2 I believe).

It is a part of Winsock 2, which I doubt anyone here doesn't have on their Windows machine. As for why it is causing that error though, who knows. I have always tried avoiding DLLs calls with VB6 since they often just cause more problems.
Reply
#7
Ah, ultimate doesn't have the limit, only Home Basic and Premium.
I wasn't able to host until I raised the max open connections.
Reply
#8
If you have to have more than 10 half-open connections for a game server, you should be seriously concerned unless you have at least 5 players logging in every second (before anyone gets cocky, thats 300 players a minute, which is more than a lot of game servers have for total active connections). All half-open ports are is a port that has started a 3-way TCP handshake but has not yet finished it. The reason you only really see anything about half open connections being related to p2p programs, namely torrents, is that once you get a list of peers, which can be in the thousands, the program is not really done until it tries to connect to each one and find out if they have a valid version of the file, if they have any parts you need, and if they have a decent speed. The thing limiting you is the rate of connections. Since people you are connecting to are mass uploading and downloading, the connection may take a while to finalize since they are trying to connect to others and others are trying to connect to them, too. It results in a big fat internet traffic jam.

Why doesn't this apply to game servers? Simply put, you have one client making a connection to one server (or sometimes a few others in rare cases) and thats it. The server is dishing out lots of data, receiving a bit, but not often will it even hit the peek (if it does, you now have bandwidth lag and a lot of complaining players) since game servers are designed to optimally, at peak times, tickle the bandwidth limit but never hit it.

Only time I can ever think of there being an exception without your whole server already running like crap is that if you have thousands of players trying to connect simultaneously, which may happen after a quick reboot. In this case, I believe those who try to connect while there max half-open connection limit is in play will either be queue'd or given a TCP rejection message (not positive which). By the time they try again (probably a second or two later) it will probably be fine.
Reply
#9
Well ,I dunno, I don't know much about networking. All I know is I was unable to host a Mirage, XW, RF, PW, or Teamspeak server until I raised the limit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)