Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

 

       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

Code today gone tomorrow!
  • 1 year later...
Posted

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

Posted

Ooops!

 

I just realised how idle this thread was!

Excuse me I found this on a search engine, but I solved the problem if anyone is reading, simply use System.text.encoding.unicode.getWhatever()

instead of ASCII.

 

/me Slaps forehead!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...