I'm trying to write a program that will send a packet to a game server (Halo CE), and get data in return from it that shows the players in the server, the current map and variant name, the server name, etc.
This is what I know so far:
- It's either based on the GameSpy V1 or GameSpy V2 Protocol
- It's UDP
- If it's V1, the packet would look simply like this: \players or \stats\; If it's V2, the packet would look more like this: \xFE\xFD\x00\x43\x4F\x52\x59\x00\xFF\xFF\x00 or similar.
This is my current code:
When pressing btnAddServer, no data is received. If I convert the bytes that are being sent into a string, the string that shows is simply "System.Byte[]"
Any ideas on how to make this work?
This is what I know so far:
- It's either based on the GameSpy V1 or GameSpy V2 Protocol
- It's UDP
- If it's V1, the packet would look simply like this: \players or \stats\; If it's V2, the packet would look more like this: \xFE\xFD\x00\x43\x4F\x52\x59\x00\xFF\xFF\x00 or similar.
This is my current code:
Code:
Option Explicit On
Imports System.Net
Imports System.IO
Imports System.Net.Sockets
Imports System.Text.Encoding
Public Class addServerInstance
Dim publisher As New Sockets.UdpClient(0)
Dim subscriber As New Sockets.UdpClient(0)
Dim InfoIsGood As String
Private Sub addServerInstance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
subscriber.Client.ReceiveTimeout = 100
subscriber.Client.Blocking = False
End Sub
Function AddServerInstanceDetails()
dataRecv.Enabled = True
publisher.Connect(txtServerIPAddress.Text, txtPort.Text)
Dim sendBytes() As Byte = ASCII.GetBytes("\xFE\xFD\x00\x43\x4F\x52\x59\x00\xFF\xFF\x00")
publisher.Send(sendBytes, sendBytes.Length)
End Function
Private Sub btnAddServer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddServer.Click
addServerInstance()
End Sub
Private Sub dataRecv_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dataRecv.Tick
Try
Dim ep As IPEndPoint = New IPEndPoint(IPAddress.Any, txtPort.Text)
Dim rcvBytes() As Byte = subscriber.Receive(ep)
txtServerDataRawDisplay.Text = ASCII.GetString(rcvBytes)
Catch ex As Exception
End Try
End Sub
End Class
Any ideas on how to make this work?