Creates a new instance of the ServerInfo class and queries a server.
A new ServerInfo class initialized with server information, or null
if the server didn't return any information.
If port is set to 0, GameStat will try to guess it. If type is a generic protocol and port can not be guessed, an ArgumentException will be thrown.
Exception Type | Condition |
---|---|
SocketException | An error occurred when attempting to access the server. |
ArgumentOutOfRangeException | The given type is not recognized by GameStat. |
ArgumentException | An invalid argument was given. |
NotImplementedException | Support for the given type is not implemented yet. |
CorruptPacketException | A currupt or unknown packet was recieved from the server. |
This example queries a QuakeWorld server and writes the resulting information to the console.
[C#]
try {
ServerInfo info=ServerInfo.Query(GameType.QuakeWorld, "quake.sol.net", 27511);
if(info!=null) {
Console.WriteLine("Host: "+info.Host);
Console.WriteLine("Mod: "+info.Mod);
Console.WriteLine("Map: "+info.Map);
Console.WriteLine("Players: {0}/{1}", info.NumPlayers, info.MaxPlayers);
}
else Console.WriteLine("Server didn't return any info.");
}
catch(Exception ex) {
Console.Error.WriteLine("An Exception Occured!");
Console.Error.WriteLine(ex.ToString());
}
ServerInfo Class | GameStat Namespace | ServerInfo.Query Overload List