|
-
Nov 9th, 2005, 12:37 PM
#1
Thread Starter
Lively Member
Gameserver Query
Hi there.
I play this game, which available online games are visible thru a game browser called GameSpy.
The available games are visible on the 'game-list' when I refresh the list in GameSpy.
I have found out how this works by using a packet sniffer on the GameSpy browser while it sends a refresh request to the server.
It will send this string to MY server '\status\'.
The server will then reply with a string like this '\name\BigGame\players\32\credits\1000\'.
This answer I recieved from the server contains the game info for the server that's running. Above you see the name of the game is 'BigGame', maximum amount of allowed players is '32', starting credits will be 1000.
I have managed to retrieve this data using PHP with simple fsockopen and fread and thus, although I am a newbie to VB and I have basicly no idea where to start.
I don't want to use gamespy everytime I want to refresh the list of games, neither do I want to use a script on a webpage. I want a program on my desktop (A VB app) to be able to refresh my game, so that I can see playernumber etc.
Since UDP is a 'connection-less' protocol, I will also not be able to verify if the packets have been routed correctly and has been recieved by the server. Still I need to be able to send this short string I have ('\status\'), and recieve the answer from the server.
The Visual Basic code I have by now is this:
VB Code:
Option Explicit
Private Sub Command1_Click()
With Winsock
.RemoteHost = Text1.Text
.RemotePort = 25300
.Close
.Connect
End With
End Sub
Private Sub Winsock_Connect()
Winsock.SendData "/status/"
End Sub
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim X As String
Winsock.GetData X
Debug.Print X
Text3.Text = X
End Sub
Private Sub Winsock_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Debug.Print "Error "; Description
End Sub
On my form..
Text1 is a textfield where a user is allowed to set the IP address of the host it wants to view games on. For ease its default caption is the IP of my server, which this app will primarily be used for.
The port is a constant, the user is forced to use port 25300 as its the port the game runs on, no other ports are needed. The Winsock1.SendData value will also be a constant, as I will only need to send '\status\' each time.
Text3.Text is yet another textfield I have on my form, where the output, or response from the server is supposed to come.
The above code you see, is what I got this far.
My simple purpose of this is, to send a simple string of data ('\status\') over the UDP protocol, and wait for an answer from the server, which is supposed to be output in my Text3 field.
The data is supposed to be sendt when I click my send button, which is labelled Command1.
As you probably see from the above code, which is my full code there IS some errors or mistakes I have made. I have verified that my code is buggy by sniffing its outgoing packets. None were sendt. Therefore I should neither expect any reply.
So first step for me towards success would get the program to actually transmit my packet containing '\status\' over the UDP protocol.
Then I need to use the other part of my code, which is supposed to listen for incoming data, to process the incoming data in the correct field, which output field is Text3.Text.
Can anyone be so kind to give me some code, sample snippets or hints on how to get this going?
Any help would be grately apprecciated.
And thanks for reading all of this, maybe a little much explanation for explaining such a simple(?) problem.
Thanks in advance!
Best Regards,
~UrlGuy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|