抱歉,如果我这几天问了很多问题
使用以下功能,我可以成功连接并登录到服务器,但问题是当它登录到服务器时,它会立即断开连接
但是当我尝试使用 autoit 登录到该服务器时,它起作用了并且它保持连接
这是我在 VB.NET 中使用的函数(它在一个类中)
Public Shared ConnectionSocket As New TcpClient
Public Shared Stream As NetworkStream
Public Shared Function Connect(ByRef IP As String, ByRef Port As Integer)
ConnectionSocket.Connect(System.Net.IPAddress.Parse(IP), Port)
Stream = ConnectionSocket.GetStream
ConnectionSocket.Client.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.KeepAlive, True)
Dim RecievedBytes(ConnectionSocket.ReceiveBufferSize) As Byte
Dim Temp As New List(Of Byte())
Dim Temp2 As New List(Of Byte())
Dim Data As Byte()
Dim Final As Byte()
Temp.Add({&H10, &H1})
Temp.Add({&H0})
Temp.Add({&H97, &H2F})
Temp.Add(UserPacket)
Temp.Add(PasswordPacket)
Temp.Add({&H0})
Temp.Add({&H1})
Temp.Add({&H0})
Temp.Add({&H77, &HD1, &HCA, &HC3, &HEB, &H3A, &H2, &H81, &HDB, &HA, &H51})
Temp.Add({&H0})
Temp.Add({&H69, &H6E, &H74, &H6C})
Temp.Add({&H0, &H0, &H0})
Temp.Add(StringToByte(My.Settings.BotUsername))
Temp.Add({&H0})
Data = Temp.SelectMany(Function(x) x).ToArray()
Temp2.Add(IntegerToByte(Data.Length - 4))
Temp2.Add(Data)
Final = Temp2.SelectMany(Function(x) x).ToArray()
Stream.Write(Final, 0, Final.Length)
While True
Try
Stream.Read(RecievedBytes, 0, CInt(ConnectionSocket.ReceiveBufferSize))
Catch ex As Exception
End Try
End While
End Function
我在 MainForm_Load 上调用此函数
如果还发布 autoit 代码有帮助,请告诉我将其添加到此处