Ping an IP's :-).
by Jan Sorensen · in Torque Game Engine · 01/14/2011 (9:17 am) · 22 replies
Hi here :-)
I'm sitting here with my good old TGE1.3 and I have a problem and hope for help.
My problem is, I can't find a 'script function-call' there just Ping an IP's and return for 'active/no active'
Can anyone here give me a hint please?
PS: I do not want a complete list mechanism, only a return for 'true', active and a 'false' for not active. I'm sure Torque has this script command?
Jan :-).
I'm sitting here with my good old TGE1.3 and I have a problem and hope for help.
My problem is, I can't find a 'script function-call' there just Ping an IP's and return for 'active/no active'
Can anyone here give me a hint please?
PS: I do not want a complete list mechanism, only a return for 'true', active and a 'false' for not active. I'm sure Torque has this script command?
Jan :-).
About the author
My 'little hobby project': http://www.virtuchat.com/
#2
I'm not sure how I use the command, so I have try this only to see what happent:
%obj = new TCPObject("nn.nn.nn.nn:nnnnn");
echo("Active?: ",%obj);
But it's always returned the number '1836' independent of the servers were active or not, so this is not the right way to do it ? :-O...
I am receptive for suggestions. Jan :-).
01/16/2011 (7:59 pm)
Hi Thomas and thanks for answers :-)I'm not sure how I use the command, so I have try this only to see what happent:
%obj = new TCPObject("nn.nn.nn.nn:nnnnn");
echo("Active?: ",%obj);
But it's always returned the number '1836' independent of the servers were active or not, so this is not the right way to do it ? :-O...
I am receptive for suggestions. Jan :-).
#3
But it was my fault. Sorry. You can not use TCPObject to ping a IP.
01/17/2011 (9:19 am)
What you got was the ID of the created TCPObject. The ID is stored in %obj. But it was my fault. Sorry. You can not use TCPObject to ping a IP.
#4
Jan :-).
01/17/2011 (1:29 pm)
It is quite alright, we have to hope another wise man walks past my posts and come with a proposal.Jan :-).
#5
01/17/2011 (2:18 pm)
I have no idea how to do this, but have you looked in the common folder to see how torque pings the server? You may be able to adapt that code to ping your users ip.
#6
01/17/2011 (5:46 pm)
I found something in serverQuery.cc. static void processPingsAndQueries( U32 session, bool schedule )
{
//...
}
#7
Okay I must find the old Ver. 1.3 'Ping Servers CS/GUI-script', because we don't use this script directly in our project, maybe I can find some interesting stuff there.
I will also try to do some experiments with the 'processPingsAndQueries' function in the Engine. I hope I can figure out what kind of parameters 'U32 session, bool schedule' is ??
Because I'm not a 'scripting expert' :-|.
More follow. Jan :-).
01/17/2011 (10:12 pm)
@ Mike and Thomas. Thanks for answers :-).Okay I must find the old Ver. 1.3 'Ping Servers CS/GUI-script', because we don't use this script directly in our project, maybe I can find some interesting stuff there.
I will also try to do some experiments with the 'processPingsAndQueries' function in the Engine. I hope I can figure out what kind of parameters 'U32 session, bool schedule' is ??
Because I'm not a 'scripting expert' :-|.
More follow. Jan :-).
#8
01/18/2011 (12:34 am)
I think what you are looking for is in common/server/scripts/clientConnections.cs (tge 1.4-1.5) That's where the server connects to each client. %netAddress I believe would get the clients ip address, but I'm not sure. It's something more concrete to look at.
#9
In the first case i can help you:
01/18/2011 (7:26 am)
Do you want to ping a connected client in your game or do you want to ping google.de (for example)?In the first case i can help you:
%clCount = clientGroup.getCount();
for (%i=0; %i<%clCount; %i++)
{
%cl = clientGroup.getObject(%i);
%clIP = %cl.getAddress();
%clPing = %cl.getPing(%clIP);
echo("IP: " @ %clIP @ " has a Ping of: " @ %clPing @ "ms";
}
#10
As I can see,,, the 'clientConnection.cs' script talks only about what happen when the connection to the server is established, not 'is the server there??'. The '%netAddress' is yours IP and not the server you asking for, but maybe I'm going wrong there?
@ Thomas:
No I only wish to test for.. Is the server I wish to connect active or not active. If yes, I go further and try to connect. The server I talk about is another 'Normal Torque server from my own server system'.
Jan :-).
01/18/2011 (1:00 pm)
@ Mike:As I can see,,, the 'clientConnection.cs' script talks only about what happen when the connection to the server is established, not 'is the server there??'. The '%netAddress' is yours IP and not the server you asking for, but maybe I'm going wrong there?
@ Thomas:
No I only wish to test for.. Is the server I wish to connect active or not active. If yes, I go further and try to connect. The server I talk about is another 'Normal Torque server from my own server system'.
Jan :-).
#11
01/18/2011 (4:57 pm)
OK. For this case i made a DLL because i needed exactly this function to ping any machine (for my own master server).
#12
The closest I can find is this function from 'joinServerGui.cs', but I can not really figure out how to use it to test for a single active server IP.
//----------------------------------------
function JoinServerGui::query(%this)
{
queryMasterServer(
0, // Query flags
$Client::GameTypeQuery, // gameTypes
$Client::MissionTypeQuery, // missionType
0, // minPlayers
100, // maxPlayers
0, // maxBots
2, // regionMask
0, // maxPing
100, // minCPU
0 // filterFlags
);
}
If I try to apply it somehow, I get this in the Console:
No master servers found in this region, trying IP:74.63.12.22:28002.
Requesting the server list from master server IP:74.63.12.22:28002 (2 tries left)...
Active?:
Received server list packet 1 of 1 from the master server (1 servers).
Pinging Server IP:96.224.211.35:28000 (3)...
You do not meet the minimum protocol for server IP:96.224.211.35:28000.
Hmmm Jan :-|.
01/18/2011 (7:45 pm)
Hi again :-)The closest I can find is this function from 'joinServerGui.cs', but I can not really figure out how to use it to test for a single active server IP.
//----------------------------------------
function JoinServerGui::query(%this)
{
queryMasterServer(
0, // Query flags
$Client::GameTypeQuery, // gameTypes
$Client::MissionTypeQuery, // missionType
0, // minPlayers
100, // maxPlayers
0, // maxBots
2, // regionMask
0, // maxPing
100, // minCPU
0 // filterFlags
);
}
If I try to apply it somehow, I get this in the Console:
No master servers found in this region, trying IP:74.63.12.22:28002.
Requesting the server list from master server IP:74.63.12.22:28002 (2 tries left)...
Active?:
Received server list packet 1 of 1 from the master server (1 servers).
Pinging Server IP:96.224.211.35:28000 (3)...
You do not meet the minimum protocol for server IP:96.224.211.35:28000.
Hmmm Jan :-|.
#13
What happens here: If you host a game, your copy of the game is sending some values to the masterserver via the heartbeat-function (IP, gametype, regionmask and so on). If a client wants to connect to a game, his copy of the game is connecting the masterserver to get the list of available hosts. And at this time, each host is ping'ed (see post #6).
What you should do:
#1: The server has to send a heartbeat to the mastersever of GG (or your own masterserver).
#2: Connect to the masterserver, get the list of the host(s) and you have your ping.
#3: If you don't want step #1 and #2, you should implement your own ping-function (see post #11).
01/19/2011 (6:15 am)
What you do with JoinServerGui::query(%this) is connecting to the masterserver of GG. What happens here: If you host a game, your copy of the game is sending some values to the masterserver via the heartbeat-function (IP, gametype, regionmask and so on). If a client wants to connect to a game, his copy of the game is connecting the masterserver to get the list of available hosts. And at this time, each host is ping'ed (see post #6).
What you should do:
#1: The server has to send a heartbeat to the mastersever of GG (or your own masterserver).
#2: Connect to the masterserver, get the list of the host(s) and you have your ping.
#3: If you don't want step #1 and #2, you should implement your own ping-function (see post #11).
#14
We working with another 'basic system'. We have a number of active servers running, one server for each zone you can login to.
Besides this, we have a 'MMO Master server' whose job is to remember/administrate users' inventory accounts and other useful things as controlling of 'login name and passwords'.
Our master server is not a Torque engine, but a separate developed program for this purpose.
You go through a portal to get from one zone to another (do a server change). If one of these servers for any reason are not active, it would be nice to test whether the server is active so the zone you are in not will be 'shot down' and you just end up with a boring 'Time Out' sign.
We not use the GG master server and we not have a master server with a server list you can ping, so therefore my question for a possibility to 'call a server' before a login.
I hope my explanation is reasonably understandable, for I am not an English expert
:-D..
Jan :-).
01/19/2011 (11:34 am)
Let me try to explain..We working with another 'basic system'. We have a number of active servers running, one server for each zone you can login to.
Besides this, we have a 'MMO Master server' whose job is to remember/administrate users' inventory accounts and other useful things as controlling of 'login name and passwords'.
Our master server is not a Torque engine, but a separate developed program for this purpose.
You go through a portal to get from one zone to another (do a server change). If one of these servers for any reason are not active, it would be nice to test whether the server is active so the zone you are in not will be 'shot down' and you just end up with a boring 'Time Out' sign.
We not use the GG master server and we not have a master server with a server list you can ping, so therefore my question for a possibility to 'call a server' before a login.
I hope my explanation is reasonably understandable, for I am not an English expert
:-D..
Jan :-).
#15
01/19/2011 (12:17 pm)
Now it is more understandable. If you only use Windows, i can write you a special DLL to ping the server you want. Otherwise you have to use "processPingsAndQueries" (see post #6).
#16
First .. Our entire system is Windows based, but is it not a 'little violently' to create a custom DLL for this purpose? But up to you :-).
But remember, I hope it just can end up in as a simply function-call.
You write.. Why not use the 'processPingsAndQueries' function? Because as I wrote in #7, I still have not understood how I use it.
Jan :-).
01/19/2011 (5:15 pm)
Hi again Thomas :-).First .. Our entire system is Windows based, but is it not a 'little violently' to create a custom DLL for this purpose? But up to you :-).
But remember, I hope it just can end up in as a simply function-call.
You write.. Why not use the 'processPingsAndQueries' function? Because as I wrote in #7, I still have not understood how I use it.
Jan :-).
#17
Not for me, because my DLL has a lot more functions than only a normal ping-function. ;-)
Because i have only limited knowledge about C/C++. But i am working with Delphi since years.
Yes, it is only a simple function-call. Do you want a special name for this function?
01/19/2011 (5:27 pm)
Quote:
Our entire system is Windows based, but is it not a 'little violently' to create a custom DLL for this purpose?
Not for me, because my DLL has a lot more functions than only a normal ping-function. ;-)
Quote:
Why not use the 'processPingsAndQueries' function?
Because i have only limited knowledge about C/C++. But i am working with Delphi since years.
Quote:
But remember, I hope it just can end up in as a simply function-call.
Yes, it is only a simple function-call. Do you want a special name for this function?
#19
Name? no up to you..
My Mail:
jansteendk 'snabel@' hotmail.com, see also my profile.
Don't forget.. ZIP it and tell me in the Mail how I use the function (parameters).
Jan :-).
01/19/2011 (7:06 pm)
Very fine :-)...Name? no up to you..
My Mail:
jansteendk 'snabel@' hotmail.com, see also my profile.
Don't forget.. ZIP it and tell me in the Mail how I use the function (parameters).
Jan :-).
#20
01/19/2011 (7:30 pm)
I sent the mail to jansteendk (at) hotmail.com
Torque 3D Owner Thomas Bang