• Welcome to Valhalla Legends Archive.
 

udp support

Started by killer, July 13, 2003, 07:33 PM

Previous topic - Next topic

killer

can anyone give me a general idea of what all i have to do to get udp support working in my bot.

thanks in advance

Soul Taker

For true UDP support, you must send the UDP pings to Battle.net.  To do this, bind a UDP socket to port 6112.  Then when you recieve 0x50, send the server hash and the third DWORD from 0x50 as packet 0x09 on the UDP socket.  Then, Bnet should send you packet 0x05 to the UDP socket.  Take the first DWORD, and send that as packet 0x14 to Bnet (via TCP).  That explaination sucks so here's some crappy code:


sckUDP.Bind 6112 'binds the UDP socket to port 6112

Upon recieving 0x50:
strUDPVal = Mid(strData, 13, 4) 'gets the value to send in the UDP pings
p.InsertDWORD ServerHash
p.InsertDWORD CVL(strUDPVal)
p.SendUDP &H9
p.InsertDWORD ServerHash
p.InsertDWORD CVL(strUDPVal)
p.SendUDP &H9
p.InsertDWORD ServerHash
p.InsertDWORD CVL(strUDPVal)
p.SendUDP &H9 'sends three UDP pings, I'd recommend making sure you actually are still connected to Bnet, cause it seems to not like getting UDP pings when not connected via TCP

Then just grab the DWORD (usually 'bnet', but hardcoding sucks) from 0x05 on the UDP socket, and send:
s.SID_UDPPINGRESPONSE Socket, frmMain.strUDPCheck

And here is the easy layout of that packet:
Public Function SID_UDPPINGRESPONSE(Socket As Integer, strVal As String)
p.InsertNonNTString strVal
p.SendPacket frmMain.sckBnet(Socket), &H14
End Function

Hope you can figure that out, I'm kinda tired and not thinking straight right now.

UserLoser

What about UDP for games, such as Broodwar?  Want to share on that? :P

killer

#3
thanks for the info and is there any importent info i should know about in-game support?


EDIT-userloser posted the same reply 2 seconds befor me lol

UserLoser

#4
I've got a start, never very far though.  You need a UDP checksum formula.

Spht

Quote from: UserLoser on July 13, 2003, 10:23 PM
I've got a start, never very far though.  Apparently, you need some UDP checksum algorithm or something.

Such checksum is computed from Storm.dll. Enjoy.

Lenny

What ways are available not for "true" udp support but just avoiding that plug?...
The Bovine Revolution
Something unimportant

Live Battle.net:

WARNING: The preceding message may have contained content unsuitable for young children.

Camel

#7
Quote from: Lenny on August 14, 2003, 02:06 AM
What ways are available not for "true" udp support but just avoiding that plug?...

The idea of requiring the client to connect via UDP and get the 'bnet' code is to prove that it really has udp support and isn't just faking it. Fortunately for the lazy among us, Blizzard has never to my knowledge changed the value -- it has always been 'bnet'. For that reason, it is probably safe to assume it will always be 'bnet' and you can send that value in 0x14 without connecting to battle.net via UDP.

[edit] 'bnet' not 'BNET'; my memory sucks.

Skywing

#8
Quote from: Camel on August 14, 2003, 02:35 AM
Quote from: Lenny on August 14, 2003, 02:06 AM
What ways are available not for "true" udp support but just avoiding that plug?...

The idea of requiring the client to connect via UDP and get the 'BNET' code is to prove that it really has udp support and isn't just faking it. Fortunately for the lazy among us, Blizzard has never to my knowledge changed the value -- it has always been 'BNET'. For that reason, it is probably safe to assume it will always be 'BNET' and you can send that value in 0x14 without connecting to battle.net via UDP.
It might be a good idea to note that the value is actually 'bnet' and not 'BNET'.

FuZe

If you are on starcraft, I think starcraft binds to port 6112, so you cant send UDP packets on that port, but it doesn't really matter if you only want to get the plug.

TeamProx

UDP can bind to port 6112 while TCP is already bound to port 6112. This is because they are different network protocols, so sending and receiving data on UDP:6112 won't be sent and received from TCP:6112. However, under normal circumstances, you shouldn't be able to bind to port 6112 multiple times with the same protocol, without unbinding the previously-bound socket.

tA-Kane

Quote from: FuZe- on August 14, 2003, 03:56 PMIf you are on starcraft, I think starcraft binds to port 6112, so you cant send UDP packets on that port, but it doesn't really matter if you only want to get the plug.
Not sure about the Windows versions, but on the Mac, if UDP port 6112 is already taken, then StarCraft (and presumably the other games) increment the port number and try to bind again. I know this because I've had two copies of StarCraft playing in a game, one was bound to port 6112 and the other on 6113.

If StarCraft had given up if it couldn't get 6112, then the second client would not have been able to play (and would have even likely reported no UDP to the server when connecting).
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Skywing

You can actually share port 6112 with Starcraft - it doesn't work perfectly, but it does (mostly) work.  See SO_REUSEADDR and setsockopt.

You can set the game to use a specific UDP port by setting a REG_DWORD named Game Data Port in HKEY_CURRENT_USER\Software\Battle.net\Configuration.

TeamProx

Quote from: Skywing on August 14, 2003, 08:30 PM
You can actually share port 6112 with Starcraft
How does this occur? Do both sockets receive the data? According to MSDN, what occurs when multiple sockets are bound to the same port is "undefined as to which port will receive packets."... personally, I wouldn't trust it to work in all versions of Windows, just because you've had luck with it.

Skywing

#14
Quote from: TeamProx on August 14, 2003, 09:02 PM
Quote from: Skywing on August 14, 2003, 08:30 PM
You can actually share port 6112 with Starcraft
How does this occur? Do both sockets receive the data? According to MSDN, what occurs when multiple sockets are bound to the same port is "undefined as to which port will receive packets."... personally, I wouldn't trust it to work in all versions of Windows, just because you've had luck with it.
It sounded like what people wanted to do was send and not receive with that --- which works fine in my experience.

Of course, a much better solution is to let the operating system pick an unused port for you and use the port selection messages to tell Battle.net that you're using that port and not 6112.  To observe this, set REG_DWORD Game Data Port in HKEY_CURRENT_USER\Software\Battle.net\Configuration.