Halflife Query

a_jam_sandwich

Well-known member
Joined
Dec 10, 2002
Messages
367
Location
Uk
Im just messing around with sockets as uptill now I not really touched it. Anyway I want to create a server query tool for halflife servers.

Here is the code so far very simple as you will see

Code:
        Dim MyUDP As New UdpClient
        Dim MyIP As IPAddress = IPAddress.Parse("195.149.21.70")
        MyUDP.Connect(MyIP, 27015)
        Dim Command As [Byte]()
        Command = Encoding.ASCII.GetBytes(Chr(255) & Chr(255) & Chr(255) & Chr(255) & "players")
        MyUDP.Send(Command, Command.Length)
        Console.WriteLine("Sent")
        Dim RemoteIpEndPoint As New IPEndPoint(MyIP, 27005)
        Try
            Dim receiveBytes As [Byte]() = MyUDP.Receive(RemoteIpEndPoint)
            Dim returnData As String = Replace(Encoding.ASCII.GetString(receiveBytes), Chr(0), "|")
            Console.WriteLine(returnData)
        Catch ex As Exception
            Console.WriteLine(ex.ToString())
        End Try
        MyUDP.Close()

The problem is Im not receiving any packets back the protocol is as from I have done this in PHP and it worked.

http://phxx.net/faq.asp?pid=22

Anyone have any ideas

Thanks

Andy
 
Hey all, new user here.
I joined the forums purely to reply to this. As I am going through the same problem. Basically Ive investigated my problem and localised it in the ascii.getBytes() and getString() methods.

What I did?

Using a packet sniffer I listened in on my client "pinging" the server for info (Im working with good ole fashioned CS on the steam engine) and where the
"...." or FF FF FF FF should appear I got "????" which from my old VB6 days I knew was a string conversion problem.

So I whipped up a bit of code to test the .NET methods ....

Assuming you have a button and two text boxes (keeping their default VS.NET names)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = ASCII.GetString(ASCII.GetBytes(TextBox1.Text))
End Sub

Simple eh? now in textbox1 hold ALT and punch in 0255 on the keyPAD (not the row above your letters) you should see a -> "
 

Similar threads

J
Replies
0
Views
63
Jessi_ca
J
P
Replies
0
Views
176
Policy standard local admin account with Active Di
P
P
Replies
0
Views
113
programmervb.net
P
Back
Top