• Welcome to Valhalla Legends Archive.
 

Battlenet Connection

Started by MindArchon, August 26, 2004, 02:43 AM

Previous topic - Next topic

MindArchon

Quote from: bethra on August 27, 2004, 03:39 PM
This one I use to send a BNCS packet buffer.  It is the one that is already in the DarkMinion's Packet buffer class

Public Function SendBNCS(socket As Winsock, PacketID As Byte)
   socket.SendData Chr(&HFF)
   socket.SendData Chr(PacketID)
   socket.SendData MakeWORD(Len(Buffer) + 4)
   socket.SendData Buffer
   Clear
End Function


This one I used to send a BNLS packet buffer.

Public Function SendBNLS(socket As Winsock, PacketID As Byte)
'//
'(WORD) Message size, including this 3-byte header
'(BYTE) Message ID
'(....) Message-dependant data
   
   socket.SendData MakeWORD(Len(Buffer) + 3)
   socket.SendData Chr(PacketID)
   socket.SendData Buffer
   Clear
End Function


Its ok bethra, I figured out how to do it on my own. Great, I think I have everything I need. Time to attempt to make my first winsocket bot!

BaDDBLooD

There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

Sorc.Polgara

wait, heh while here

is mine correct?

Public Function SendBNLS(socket As Winsock, PacketID As Byte)
'//
'(WORD) Message size, including this 3-byte header
'(BYTE) Message ID
'(....) Message-dependant data
 
   socket.SendData MakeWORD(Len(Buffer) + 3)
   socket.SendData Chr(PacketID)
   socket.SendData Buffer
   Clear
End Function


Sometimes when I send with it tehre is no problem.  but soemtimes I get a runtime error

Quote
Run-time error '40006':

Wring Protocol or connection state for the requested transaction or request

Dunno, it works sometimes when I try to send data to BNLS but then sometimes it displays this run-time error.

huh?

K

That means that the socket was closed, and you tried to send data on it.  

You should check if the socket is connected (ie, State is vbStateConnected or whatever) before trying to write to it.

Blaze

#34
Heres what I use for bnls packetsend...


Public Function SendBNLSPacket(PacketID As Byte)
On Error Resume Next
If frmMain.sckBNLS.State <> 0 Then
frmMain.sckBNLS.SendData MakeWORD(Len(Buffer) + 3) & Chr(PacketID) & Buffer
Clear
End if
End Function


Edit:

Why would you need to specify which socket you use? Why would you need more then one for bnls?
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

BaDDBLooD

On Error Resume Next isn't very good.  Ignoring a problem will usually cause more problems in the end.
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

Blaze


Public Function SendBNLSPacket(PacketID As Byte)
If frmMain.sckBNLS.State <> 8 Then
frmMain.sckBNLS.SendData MakeWORD(Len(Buffer) + 3) & Chr(PacketID) & Buffer
Clear
End if
End Function
Quote
Mitosis: Haha, Im great arent I!
hismajesty[yL]: No

ChR0NiC


Public Function SendBNLSPacket(PacketID As Byte)
If frmMain.sckBNLS.State = sckConnected Then
frmMain.sckBNLS.SendData MakeWORD(Len(Buffer) + 3) & Chr(PacketID) & Buffer
Clear
End if
End Function


This way, you will be 100% sure you are connected so you won't crash your bot when it thinks it's alright to send.

MindArchon

#38
So, ive connected to BNLS and got the versionbyte. Ive read on these forums, the first thing you send to bnet after connection is 0x01? I dont get the format for it.

This is what it says on bnet docs


(DWORD[16])    MCP Startup Data
(STRING)            Battle.net Unique Name



Whats a MCP Startup Data, and whats "Battle.net Unique Name?"

PaiD

Those r apart of a different login. That is for 0x01 MCP (Also known as Diablo 2 realms) You want to look for BNCS not MCP

MindArchon

Quote from: DueL on August 28, 2004, 01:39 AM
Those r apart of a different login. That is for 0x01 MCP (Also known as Diablo 2 realms) You want to look for BNCS not MCP

Hmm, im not really sure about this..

So i send 0x01 which means I want to be able to join games. Is there anything in this packet?

ChR0NiC

Quote from: MindArchon on August 28, 2004, 01:53 AM
Hmm, im not really sure about this..

So i send 0x01 which means I want to be able to join games. Is there anything in this packet?

0x01 is not an official BNET Packet.

BaDDBLooD

you would use

Winsock.SendData Chr(1)
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

MindArchon

Quote from: BaDDBLooD on August 28, 2004, 02:04 AM
you would use

Winsock.SendData Chr(1)

Why do you have to send this. What does it actually do?

Kp

Quote from: MindArchon on August 28, 2004, 02:54 AMWhy do you have to send this. What does it actually do?

It identifies that you want to be a game client, not a {file transfer, chat} client or battle.net server.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

|