Valhalla Legends Forums Archive | Battle.net Bot Development | [VB6] Whats going wrong?

AuthorMessageTime
Sorc_Polgara
I'm trying to use the winsock component and connect, send, and recieve the response using the BNLS_AUTHORIZE message...

Since I'm just doing a test, I just made a little program using a listbox as a debug-like thing. The listbox is "lstDebug" and my winsock is named "ws". Here is the code that I am having trouble with.

[code]
Private Sub mnuConnect_Click()
Dim wsHost As String
Dim wsPort As Long
wsHost = "bnls.valhallalegends.com"
wsPort = 9367

ws.Connect wsHost, wsPort
End Sub

Private Sub mnuDisconnect_Click()
ws.Close
End Sub
Private Sub ws_Connect()
lstDebug.AddItem "Connected!"

ws.SendData &HB
ws.SendData &HE
ws.SendData "polgara\0"
End Sub

Private Sub ws_SendComplete()
lstDebug.AddItem "Sent Login ID"
ws_Is_Sending = False
End Sub

Private Sub ws_DataArrival(ByVal bytesTotal As Long)
Dim strData As String

ws.GetData strData, vbString, bytesTotal

lstDebug.AddItem "Data Recieved"
lstDebug.AddItem strData
End Sub

Private Sub ws_Close()
lstDebug.AddItem "Disconnected!"
End Sub

Private Sub ws_SendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)
ws_Is_Sending = True
End Sub
[/code]

&HB is the message size including the 3-byte headerpart of the BNLS message format. "polgara" is like 8 bytes (including the NT byte) + 3 more bytes which is 11.

&HE is the message ID, BNLS_AUTHORIZE (0x0e)

Its not all but most of the basic code. I made a menu named "mnuConnect" so that when I click on it I will... doh, connect :).

When I click the menu, the debug listbox shows
[code]
Connected!
Sent Login ID
Disconnected!
[/code]

It seems like I am able to connect to BNLS and send my login ID "polgara" but get no response from BNLS... Probably something to do with what I am sending. Can I get some help on what I am doing wrong?
June 21, 2004, 8:18 PM
Stealth
Edit: You are appending a header. Nevermind. I should read posts before replying.

In that case, the problem is here:

[quote] "polgara\0" [/quote]

VB doesn't have escape characters like other languages do. What you sent above was the string "polgara\0", forward slash, zero and all, which the BNLS server will probably reject because the packet size is now 12 but the header says it's 11. If that doesn't occur, it will reject you because the BNLS account "polgara\0" probably doesn't exist.

In order to null-terminate it you have to say:

[quote] "polgara" & Chr(0) [/quote]

Hope that helps.
June 21, 2004, 10:22 PM
StepAside
By the why, what is the reponse type? A boolean contained in a DWORD? Or something to that effect? Listboxes and RTB's have trouble displaying such data types as you may THINK they will be displayed, but I'd try Stealth's idea first.
June 22, 2004, 6:01 PM
Stealth
He's right, you should probably use something like DebugOutput to produce a more easily-readable format for that incoming data. The listbox won't like a bunch of null characters.
June 22, 2004, 9:34 PM
Sorc_Polgara
Its the BNLS_AUTHORIZE.. suppose to responed with a DWORD, servercode

I have a BNLS account, "polgara" it exists... I've used CSB with it...

Problem is that it doesn't even recognize that data has arrived.

[code]
Private Sub ws_DataArrival(ByVal bytesTotal As Long)
Dim strData As String

ws.GetData strData, vbString, bytesTotal

lstDebug.AddItem "Data Recieved"
lstDebug.AddItem strData
End Sub
[/code]

Even if it were the list box, I would of atleast know that data has arrived...

Here is what I get from the list box, again.

[code]
Connected!
Sent Login ID
Disconnected!
[/code]

if any data has arrived... I would of seen

[code]
Connected!
Sent Login ID
Data Recieved
Disconnected!
[/code]

I'm not getting any data response... therefore even if I knew how to use the debugoutput module (which I don't) it would be useless until I recived data :\

I tried changing "polgara\0" to what stealth said, "polgara" & chr(0)

still no data recieved.
June 25, 2004, 9:31 PM
UserLoser.
You're sending 11 (0xb) as the length, when (("polgera" * chr(0) = 8) + (id = 1) + (packet len byte = 1)) = 10, not 11. Since you're sending 11, the server is probably waiting for 2 more bytes of data from you
June 25, 2004, 9:40 PM
Sorc_Polgara
Changed it to 10 (0x0A)

[code]
ws.SendData &HA
ws.SendData &HE
ws.SendData "polgara" & Chr(0)
[/code]

Wow, BNLS_AUTHORIZE is like the fking easiest looking BNLS packet...

[quote]
BNLS_AUTHORIZE (0x0e)
---------------------

This message logs on to the BNLS server.

(String) Bot ID.

Note: The bot ID is not case sensitive, and is limited to 31 characters.
This message must be sent before sending any other message.

Response:
---------

If the bot ID isn't recognized by the server, the connection is terminated.
Otherwise, a response is sent:

(DWORD) Server code.
[/quote]

I can't even fking get this to work... so frustrating, I give up.
June 26, 2004, 8:02 PM
Stealth
Hah! The packet length portion of the header needs to be a WORD. You're sending it as a byte, plus 0x0E - so the server is waiting for quite a bit more data.
June 26, 2004, 10:36 PM
UserLoser.
[quote author=Stealth link=board=17;threadid=7371;start=0#msg67327 date=1088289417]
Hah! The packet length portion of the header needs to be a WORD. You're sending it as a byte, plus 0x0E - so the server is waiting for quite a bit more data.
[/quote]

Bah, by him doing .SendData 3 times, I didn't even realize that the first one should be a WORD and not a BYTE >:(

Edit: After doing small calculations, you're sending 28686 (0x700E) as the length ;)

For putting the size to a WORD, try using this function:

[code]
Private Function WORD(ByVal Data As Long) As String
Dim strResult As String * 2

Call RtlMoveMemory(ByVal strResult, Data, 2) 'RtlMoveMemory is more commonly refered to as CopyMemory
WORD = strResult
End Function
[/code]

Then you could do:

[code]
ws.SendData WORD(&HB) ' 2 bytes (packet len)
ws.SendData &HE ' + 1 byte = 3 bytes (packet id)
ws.SendData "polgara" & Chr(0) ' + 7 bytes + 1 null byte = 11 bytes (packet data)
[/code]

Hope this helps, let us know.
June 26, 2004, 10:40 PM
Sorc_Polgara
Well, I can't give feed back on if it worked mainly b/c of this hehehehe

https://davnit.net/bnet/vL/phpbbs/index.php?board=17;action=display;threadid=7476

So I don't have to worry about it anymore hehehehe

I actually learned alot though from this post and I want to thank all of you that gave helpful replies and/or tried to help me. Thanks again. :)
June 29, 2004, 6:05 PM

Search