Checking server status in C#

09/21/2008 07:47 KraHen#1
Okay guys, I`m making a launcher. I already made the IP updater in it, but I wanna do a server status checker aswell. Since my ISP is upadting some cable shit I can`t load Google (epvp and YouTube are the only sites that i can load o.o), so I`m asking this here.

How can I make a checker similar to fsockopen in C#?
09/21/2008 10:35 andyd123#2
From CoEmu's Launcher:
Code:
void UpdateStatus(IPAddress[] IP)
		{
			TcpClient GameServerCheck =  new TcpClient();
			int GamePort = 0; //The port of your game server
			try {
				GameServerCheck.Connect(IP[0], GamePort);
				
				this.Invoke((MethodInvoker) delegate
				{
				this.label3.Text = "Online";
				this.label3.ForeColor = Color.Green;
				});
			}
			catch {
				this.Invoke((MethodInvoker) delegate
				{
				this.label3.Text = "Offline";
				this.label3.ForeColor = Color.Red;
				});
			}
			TcpClient LoginServerCheck =  new TcpClient();
			int LoginPort = 0;//The port of your login server
			try {
				LoginServerCheck.Connect(IP[0], LoginPort);
				
				this.Invoke((MethodInvoker) delegate
				{
				this.label5.Text = "Online";
				this.label5.ForeColor = Color.Green;
				});
			}
			catch {
				this.Invoke((MethodInvoker) delegate
				{
				this.label5.Text = "Offline";
				this.label5.ForeColor = Color.Red;
				});
			}
		}
Basically, if it catches any error it assumes the server is offline.
09/21/2008 11:28 KraHen#3
Thanks^^

P.S. I need one more line though :D What should i add to the "using" list?
09/21/2008 11:47 andyd123#4
Code:
using System.Net;
using System.Net.Sockets;
using System.IO;
should do it.
09/21/2008 12:55 © Haydz#5
ewww tcp :(