Valhalla Legends Forums Archive | Battle.net Bot Development | 0x3E Parsing Problem

AuthorMessageTime
laurion
Alright im trying to get an IP from the DWORD in 0x3E that b.net sends back to you. I am doing this by
[code]
Server = Mid(Data, 5, 4)
frmMain.WSmcp.Connect DWORDtoIP(Server), 6112
[/code]
And i am using this to convert the dword to IP (thanks dragon)
[code]
Public Function DWORDtoIP(IPData As String) As String
Dim A As Integer, B As Integer, c As Integer, d As Integer
If IPData = "" Then
DWORDtoIP = "ERROR: Empty Data."
Exit Function
ElseIf Len(IPData) < 4 Then
DWORDtoIP = "ERROR: Bad Data length."
Exit Function
ElseIf Len(IPData) > 4 Then
DWORDtoIP = "ERROR: Bad Data length."
Exit Function
End If
A = Asc(Mid(IPData, 1, 1))
B = Asc(Mid(IPData, 2, 1))
c = Asc(Mid(IPData, 3, 1))
d = Asc(Mid(IPData, 4, 1))
DWORDtoIP = A & "." & B & "." & c & "." & d
End Function
[/code]
The only problem is, it is trying to connect to 1.0.0.0 as the server-did I do something wrong?
February 12, 2004, 8:03 PM
Spht
Wouldn't it be easier to do something like...

[code] ptr = inet_ntoa(ip)
If ptr then
ipstr = space(lstrlen(ptr))
lstrcpy(ipstr, ptr)
(ipstr is the ip)
End if[/code]
February 12, 2004, 8:20 PM
UserLoser.
[quote author=Spht link=board=17;threadid=5251;start=0#msg43866 date=1076617226]
Wouldn't it be easier to do something like...

[code] ptr = inet_ntoa(ip)
If ptr then
ipstr = space(lstrlen(ptr))
lstrcpy(ipstr, ptr)
(ipstr is the ip)
End if[/code]
[/quote]


Yes, I suggested using inet_ntoa many times before on another thread, but a moderator kept removing it
February 12, 2004, 9:54 PM
laurion
Problem solved (many thanks to UserLoser)
February 12, 2004, 10:41 PM

Search