On form load it preforms this action:
As result I get the server name of a gameserver running on that IP address with that port.
But how do I get more results from the datagram? Ive gotten this code from a Visual Basic program and that can see the current amount of players and map etc.
How can I get this to show in C#?
Code:
string IP = "*";
int Port = *;
IPEndPoint RemoteEndPoint = new IPEndPoint(System.Net.IPAddress.Parse(IP), Port);
UdpClient Client = new UdpClient();
byte[] sendDatagram = { 0xff, 0xff, 0xff, 0xff, 0x54, 0x53, 0x6f, 0x75, 0x72, 0x63,
0x65, 0x20, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x20, 0x51,
0x75, 0x65, 0x72, 0x79, 0x0 };
byte[] receiveDatagram;
try
{
Client.Send(sendDatagram, sendDatagram.Length, RemoteEndPoint);
receiveDatagram = Client.Receive(ref RemoteEndPoint);
Client.Close();
label1.Text = Encoding.ASCII.GetString(receiveDatagram, 6, 117).ToString();
labelResult.Text = receiveDatagram.Length.ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return;
}
But how do I get more results from the datagram? Ive gotten this code from a Visual Basic program and that can see the current amount of players and map etc.
How can I get this to show in C#?