Halflife Query

a_jam_sandwich

Junior Contributor
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

Visual Basic:
        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 (I'm 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 -> "ÿ"

Push your button which converts it to a byte array and then back again and textbox2 should now say "?"

Ooops the .net libraries didnt account for everything we'd want to convert :-(.

So having just discovered this my first thoughts are find or code a class that will make the conversion.

But hopefully with this info you may be able to explore some avenue ive not thought of.


Allan
 
Back
Top