Потихоньку начинаю осваивать оог. Столкнулся с проблемой после формирования и отправки пакета &H3 ничего не получаю.
Код:
Dim i As Integer
Dim client As New TcpClient("link2.pwonline.ru", 29000)
Dim skt As Socket = client.Client
Do
Try
Dim bytes(&HFF) As Byte
skt.Receive(bytes)
If bytes(0) <> 0 Then
Console.WriteLine(bytes(0))
If bytes(0) = &H1 Then ' пакет с ключем...
Dim key(15) As Byte
For i = 0 To 15
key(i) = bytes(i + 3)
Next
'Create Packet 0x03
Dim loginbt() As Byte = Encoding.GetEncoding(1251).GetBytes("MyLogin")
Dim hash() As Byte = GetHash(key, "MyLogin", "MyPass")
Dim send As New List(Of Byte)
send.Add(3)
send.Add((loginbt.Length))
send.AddRange(loginbt)
send.Add((hash.Length))
send.AddRange(hash)
send.Add((0))
send.Insert(1, send.Count)
skt.Send(send.ToArray())
End If
End If
Catch ex As ArgumentNullException
Beep()
MsgBox("ArgumentNullException: {0}")
Catch ex As SocketException
Beep()
MsgBox("SocketException: {0}")
Catch ex As System.IO.IOException
Beep()
MsgBox("Сервер принудительно разорвал соединение")
Exit Do
End Try
Loop
Код:
Private Function GetHash(ByVal key() As Byte, ByVal login As String, ByVal pass As String) As Byte()
Dim logwithpass() As Byte = Encoding.ASCII.GetBytes(login + pass)
Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
Return New HMACMD5(md5.ComputeHash(logwithpass)).ComputeHash(key)
End Function
Помогите разобраться что не так.
Добавлено через 8 часов 34 минуты
Проблема была в пакете.