Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21846

How to Send Correct Data via Csocket Class ?

$
0
0
Dear Forum members, :)

I usually make mig33 tool with Csocket class. But in few PC I got a Error. When i send packet to mig33 server 3rd byte always remains 3F . That's why I can't send correct packet to Mig33 server.

Here is a simple Login function of mig33

Code:

Public Function LoginOnline(Username As String)
    LoginOnline = HexToAsciiX("0200C80001" & DecToHexFull(Len(Username) + 123) & "0013000000010000100000000400000013000F00000005656E2D5553000D00000004000002BC000C000000040000013A000B000000040000000E000900000001010008000000046A326D6500070000000D4A324D4576342E32302E3239300005" & DecToHexFull(Len(Username)) & AsciiToHexX(Username) & "00030000000201A4000200000001020001000000020001")
End Function


Public Function AsciiToHexX(ByVal StrToHex As String) As String
    Dim strTemp As String
    Dim strReturn As String
    Dim i As Long
    For i = 1 To Len(StrToHex)
        strTemp = Hex$(Asc(Mid$(StrToHex, i, 1)))
        If Len(strTemp) = 1 Then
            strTemp = "0" & strTemp
        End If
        strReturn = strReturn & strTemp
    Next i
    AsciiToHexX = strReturn
End Function


Public Function HexToAsciiX(ByVal HexToStr As String) As String
    Dim strTemp As String
    Dim strReturn As String
    Dim i As Long
    For i = 1 To Len(HexToStr) Step 2
        strTemp = Chr$(Val("&H" & Mid$(HexToStr, i, 2)))
        strReturn = strReturn & strTemp
    Next i
    HexToAsciiX = strReturn
End Function


Public Function DecToHexFull(strAsc) As String
    strAsc = Hex(strAsc)
    If Len(strAsc) < 8 Then
        Do Until Len(strAsc) = 8
            strAsc = "0" & strAsc
        Loop
    End If
    Dim lonLen As Long
    lonLen = Len(strAsc)
    Dim i As Integer
    For i = 1 To Len(strAsc)
        strAsc = strAsc & Mid(strAsc, i, 2)
        i = i + 1
    Next i
    DecToHexFull = Mid(strAsc, lonLen + 1)
    DecToHexFull = Mid(DecToHexFull, 1, Len(DecToHexFull))
End Function

After sending LoginOnline packet to mig33 server I always get > 02 00 3F 00 01......... < . But I should send like this 02 00 C8 00 01.......... You may suggest me to use MSWINSCK.OCX But I don't like this due to it's array system. Csocket class array is easy for me.

Have you any solution please ? Help me to solve this problem please. :)

Viewing all articles
Browse latest Browse all 21846

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>