QuerySingleServer
by Howard Dortch · in Torque Game Engine · 08/20/2005 (7:44 am) · 12 replies
I'm looking for a simple way to see if a servers IP address is valid. I have an edit box for the client to enter an ip address and connect to a server. I get a crash if the ip address is wrong. It all works fine if you use the right address.
I have looked at the querySingleServer and the function onServerQueryStatus gets called but it hangs up in there during the ping routine in the engine as far as I can tell.
All I want is bool IsServerValid(IPAddress)
I dont see any console functions in the engine to give me the answer.
I have looked at the querySingleServer and the function onServerQueryStatus gets called but it hangs up in there during the ping routine in the engine as far as I can tell.
All I want is bool IsServerValid(IPAddress)
I dont see any console functions in the engine to give me the answer.
#2
123.456.789.012 is valid address and server exists there and all is well
123.456.789.013 oops, wrong address, game crashes
I was lookin for something like this if(isServerValid(123.456.789.012))
querySingleServer works but hangs in the engine during the ping test.
08/20/2005 (11:16 am)
Thats not a problem, that all works. I just need to know that the server exists at that ip address.123.456.789.012 is valid address and server exists there and all is well
123.456.789.013 oops, wrong address, game crashes
I was lookin for something like this if(isServerValid(123.456.789.012))
querySingleServer works but hangs in the engine during the ping test.
#3
08/20/2005 (3:05 pm)
It takes time to figure out if a server is valid, so unless you want to compare against a known list of good servers the function will block, taking control away from the program.
#4
08/20/2005 (3:59 pm)
You could try what some games do: A series of 3 pings to a server IP. If they fail, it won't list it this refresh round.
#5
function onServerQueryStatus(%status, %msg, %value)
I would like to think this would work and simply go through the pings and tell me it's there.
@Mike what is the console function to do a ping ?
08/20/2005 (4:27 pm)
@Ben if I do a connect like this %conn.connect($IPAddress); and the address is valid it hooks up and runs fine. So for a sanity check I tried querySingleServer with the ip address it hits the same function as queryLAN listed here.function onServerQueryStatus(%status, %msg, %value)
I would like to think this would work and simply go through the pings and tell me it's there.
@Mike what is the console function to do a ping ?
#6
08/20/2005 (6:06 pm)
@Howard - sure, and doing so in a blocking way will make things freeze up for a while, or not work at all depending on how things are implemented.
#7
I cant help believe there is a function that will return a failure mode or a structure member here I can check for an invalid IP address.
Also any clue why querySingleServer hangs up in the engine at the ping ?
08/29/2005 (8:55 am)
Bump this. I cant help believe there is a function that will return a failure mode or a structure member here I can check for an invalid IP address.
Also any clue why querySingleServer hangs up in the engine at the ping ?
#8
08/29/2005 (10:20 am)
QuerySingleServer shouldn't crash. What happens when you run in debug mode? Invalid IP addresses should not break any of the server query stuff.
#9
this is called from a button press in the gui:
function JoinServerGui::queryIP(%this)
{
echo("QUERY SINGLE SERVER CALLED");
querySingleServer($Pref::LastIpAddress,0);
}
In the function onServerQueryStatus(%status, %msg, %value) I put echo statements for each case of the switch and this is the console.log file
QUERY SINGLE SERVER CALLED
CALLING onServerQueryStatus START <<< IT CALLS THE START
Pinging Server IP:12.12.12.12:28000 (3)...
Pinging Server IP:12.12.12.12:28000 (2)...
Pinging Server IP:12.12.12.12:28000 (1)...
Pinging Server IP:12.12.12.12:28000 (0)...
Ping to server IP:12.12.12.12:28000 timed out.
the program just sits here and does nothing till I hit the back button for exit the gui and return to main menu then I get this.
CALLING JoinServerGui exit
Server query canceled.
CALLING onServerQueryStatus DONE
JOIN SERVER UPDATE CALLED
That help any ?
08/29/2005 (12:15 pm)
Ok here is what I havethis is called from a button press in the gui:
function JoinServerGui::queryIP(%this)
{
echo("QUERY SINGLE SERVER CALLED");
querySingleServer($Pref::LastIpAddress,0);
}
In the function onServerQueryStatus(%status, %msg, %value) I put echo statements for each case of the switch and this is the console.log file
QUERY SINGLE SERVER CALLED
CALLING onServerQueryStatus START <<< IT CALLS THE START
Pinging Server IP:12.12.12.12:28000 (3)...
Pinging Server IP:12.12.12.12:28000 (2)...
Pinging Server IP:12.12.12.12:28000 (1)...
Pinging Server IP:12.12.12.12:28000 (0)...
Ping to server IP:12.12.12.12:28000 timed out.
the program just sits here and does nothing till I hit the back button for exit the gui and return to main menu then I get this.
CALLING JoinServerGui exit
Server query canceled.
CALLING onServerQueryStatus DONE
JOIN SERVER UPDATE CALLED
That help any ?
#10
It's not able to connect to the server. Why not add a callback so that when the ping times out, it notifies you via script?
08/30/2005 (11:43 am)
That's not a crash, Howard. A crash is when the program exits with an error condition, usually in an unplanned and fatal way.It's not able to connect to the server. Why not add a callback so that when the ping times out, it notifies you via script?
#11
08/30/2005 (2:19 pm)
Thanks Ben I havent been around computers much so wasn't sure what a crash was.
#12
This happens sometimes when I try to connect not always.
GAME caused an invalid page fault in
module GAME.EXE at 0167:00568f7c.
Registers:
EAX=00000000 CS=0167 EIP=00568f7c EFLGS=00010216
EBX=01609e5c SS=016f ESP=00a5f790 EBP=00a5f864
ECX=015d175c DS=016f ESI=015d175c FS=441f
EDX=00000000 ES=016f EDI=00000081 GS=445e
Bytes at CS:EIP:
8b 42 08 8b 5a 0c 57 8b 79 48 8d 50 02 8b b7 ac
Stack dump:
015d175c 00a5f864 01609e5c 00569264 00a5f7c8 0056926b 00727fd0 0053d3d7 00a5f7c8 00a5f7c0 000000e6 00ea7630 0000012c 00000081 000000aa 000000af
08/30/2005 (2:35 pm)
When you check for server on the lan it returns with "No Servers Found" Why doesn't querySingleServer do the same. My previous post had nothing to do with the crash it just doesn't return like queryLan does. Crash shown below.This happens sometimes when I try to connect not always.
GAME caused an invalid page fault in
module GAME.EXE at 0167:00568f7c.
Registers:
EAX=00000000 CS=0167 EIP=00568f7c EFLGS=00010216
EBX=01609e5c SS=016f ESP=00a5f790 EBP=00a5f864
ECX=015d175c DS=016f ESI=015d175c FS=441f
EDX=00000000 ES=016f EDI=00000081 GS=445e
Bytes at CS:EIP:
8b 42 08 8b 5a 0c 57 8b 79 48 8d 50 02 8b b7 ac
Stack dump:
015d175c 00a5f864 01609e5c 00569264 00a5f7c8 0056926b 00727fd0 0053d3d7 00a5f7c8 00a5f7c0 000000e6 00ea7630 0000012c 00000081 000000aa 000000af
Associate Sam Bacsa
For example, split at the "."
Make sure there are 4 octets.
Make sure each section is > 1 and < 255