• Welcome to Valhalla Legends Archive.
 

0x3E Parsing Problem

Started by Tazo, February 12, 2004, 02:03 PM

Previous topic - Next topic

Tazo

Alright im trying to get an IP from the DWORD in 0x3E that b.net sends back to you. I am doing this by

Server = Mid(Data, 5, 4)
frmMain.WSmcp.Connect DWORDtoIP(Server), 6112

And i am using this to convert the dword to IP (thanks dragon)

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

The only problem is, it is trying to connect to 1.0.0.0 as the server-did I do something wrong?

Spht

Wouldn't it be easier to do something like...

 ptr = inet_ntoa(ip)
 If ptr then
   ipstr = space(lstrlen(ptr))
   lstrcpy(ipstr, ptr)
   (ipstr is the ip)
 End if

UserLoser.

Quote from: Spht on February 12, 2004, 02:20 PM
Wouldn't it be easier to do something like...

 ptr = inet_ntoa(ip)
 If ptr then
   ipstr = space(lstrlen(ptr))
   lstrcpy(ipstr, ptr)
   (ipstr is the ip)
 End if



Yes, I suggested using inet_ntoa many times before on another thread, but a moderator kept removing it

Tazo

Problem solved (many thanks to UserLoser)