|
-
January 22nd, 2010, 09:43 AM
#1
Server status help / code convert from VC++ to VC#
hello all, i have some problem, need to create a small form that will show server status.
Im working in Visual Studio 2010 C# language.
I have example of code but it's in VC++, i dont know how to rewrite it in VC#
this is VC++ code:
Code:
Dim tcpC As New TcpClient
Dim tcpC2 As New TcpClient
Try
tcpC.Connect(IPServer, 7777)
txtGameServer.Text = "OnLine"
txtGameServer.ForeColor = Color.Green
Catch a As Exception
txtGameServer.Text = "OffLine"
txtGameServer.ForeColor = Color.Red
End Try
tcpC.Close()
Try
tcpC2.Connect(IPServer, 2106)
txtLoginServer.Text = "OnLine"
txtLoginServer.ForeColor = Color.Green
Catch a As Exception
txtLoginServer.Text = "OffLine"
txtLoginServer.ForeColor = Color.Red
End Try
tcpC2.Close()
i need something similair for VC#
On form there is going to be something like this:
Server status: Online (or if tcp query comes in fault it says "Offline")
How can i do that, im really a newbie Plz help me
-
January 22nd, 2010, 10:49 AM
#2
Re: Server status help / code convert from VC++ to VC#
that's VB, not C++ lol.. but...
Code:
TcpClient tcpC = new TcpClient();
TcpClient tcpC2 = new TcpClient();
try
{
tcpC.Connect(IPServer, 7777);
txtGameServer.Text = "OnLine";
txtGameServer.ForeColor = Color.Green;
}
catch(Exception ex)
{
}
finally
{
tcpC.Close();
}
try
{
tcpC2.Connect(IPServer, 2106);
txtLoginServer.Text = "OnLine";
txtLoginServer.ForeColor = Color.Green;
}
catch(Exception ex)
{
}
finally
{
tcpC2.Close();
}
Last edited by mariocatch; January 22nd, 2010 at 10:52 AM.
Reason: Adding code.
-
January 22nd, 2010, 12:46 PM
#3
Re: Server status help / code convert from VC++ to VC#
This is that part:
but it wont work, its not printing out on form is it online, on form there is Game: offline part, it should print out "Online" if this scrip works 
Code:
//Server Status !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
private void Check()
{
TcpClient tcpC = new TcpClient();
TcpClient tcpC2 = new TcpClient();
try
{
tcpC.Connect("GSLS", 7777);
game.Text = "OnLine";
game.ForeColor = Color.Green;
}
catch (Exception ex)
{
}
finally
{
tcpC.Close();
}
try
{
tcpC2.Connect("GSLS", 2106);
login.Text = "OnLine";
login.ForeColor = Color.Green;
}
catch (Exception ex)
{
}
finally
{
tcpC2.Close();
}
}
//End Server status !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
January 22nd, 2010, 01:12 PM
#4
Re: Server status help / code convert from VC++ to VC#
That means your Connect() is failing... which we can't help you with the code you provided..
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
|