提问人:fpaezf 提问时间:10/14/2023 最后编辑:lsalazarfpaezf 更新时间:10/14/2023 访问量:21
使用 TcpListener 检索游戏服务器 POST 消息
Retrieve gameserver POST message with TcpListener
问:
我正在尝试从《反恐精英》游戏服务器接收数据。该游戏服务器每 X 秒使用数据对指定的 IP:PORT 执行一次 http POST。我试图用TCPListener捕获这些数据,但该函数在显示数据几秒钟后崩溃。
这是我的代码:
Imports System.Net
Imports System.Net.Sockets
Public Class Form1
Dim Listener As TcpListener
Dim port As Integer = 90
Dim localAddress As IPAddress = IPAddress.Parse("192.168.1.34")
Dim bytes(9000) As Byte
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
StartProcess()
End Sub
Private Sub StartProcess()
Listener = Nothing
Try
Listener = New TcpListener(localAddress, port)
Listener.Start()
While True
Dim client As TcpClient = Listener.AcceptTcpClient()
Dim stream As NetworkStream = client.GetStream()
Dim i As Integer = stream.Read(bytes, 0, bytes.Length)
While (i <> 0)
TextBox1.AppendText(System.Text.Encoding.ASCII.GetString(bytes, 0, i))
i = stream.Read(bytes, 0, bytes.Length) //<-HERE IS THE ERROR
End While
client.Close()
End While
Catch ex As Exception
Listener.Stop()
MsgBox("Stop")
End Try
End Sub
End Class
POST 数据似乎来自多个块或页面:
第一页:
POST / HTTP/1.1
user-agent: Valve/Steam HTTP Client 1.0 (730)
X-LogBytes-BeginOffset: 0
X-LogBytes-EndOffset: 8781
X-Tick-Start: 89
X-Tick-End: 90
X-SteamID: [A:1:4260888584:24478]
X-Server-Addr: 82.223.49.142:30015
X-Timestamp: 10/13/2023 - 11:12:33.636
X-Server-Instance-Token: a387dbb5945b983b
Content-Type: text/plain
Host: 123.123.123.123:90
Accept: text/html,*/*;q=0.9
accept-encoding: gzip,identity,*;q=0
accept-charset: ISO-8859-1,utf-8,*;q=0.7
Content-Length: 8781
第二页:
10/13/2023 - 11:02:07.782 - server_cvar: "sv_tags" "16k,CS2,Dust2,casual,espa??a,only,spain"
10/13/2023 - 11:02:07.782 - server_cvar: "sv_tags" "CS2, espa??a, spain, Dust2, 16k, only, casual"
10/13/2023 - 11:02:07.782 - Log file started (file "logs/2023_10_13_110208.log") (game "csgo") (version "9842")
10/13/2023 - 11:02:07.782 - Loading map "de_dust2"
10/13/2023 - 11:02:07.782 - server cvars start
10/13/2023 - 11:02:07.782 - "tv_enable_dynamic" = "false"
10/13/2023 - 11:02:07.782 - "tv_enable" = "false"
10/13/2023 - 11:02:07.782 - "tv_enable1" = "false"
10/13/2023 - 11:02:07.782 - "tv_relaypassword" = ""
10/13/2023 - 11:02:07.782 - "tv_password" = ""
10/13/2023 - 11:02:07.782 - "tv_advertise_watchable" = "false"
10/13/2023 - 11:02:07.782 - "sv_cheats" = "false"
10/13/2023 - 11:02:07.782 - "sv_debug_overlays_broadcast" = "false"
10/13/2023 - AND SO ON...
有什么线索可以修复错误吗?另外,我认为我错过了更多的数据页。
谢谢!
答: 暂无答案
下一个:vb.net 图未显示所有标签
评论