Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 20:01

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Client check if server socket is open C#

Discussion on Client check if server socket is open C# within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
abdeen's Avatar
 
elite*gold: 0
Join Date: Mar 2010
Posts: 475
Received Thanks: 15
Client check if server socket is open C#

i want the client check if the server socket is online or not , and if it's not it's wait 20 sec then check again .. i tried to figure it out by making this code but still doesn't make what i want ... i think there is a good solution better than the one i made .

PHP Code:
        public bool Connect(string IPint Port)
        {
            
int tries 0;
            
IPAddress ipAddress IPAddress.Parse(IP);
            
IPEndPoint ipEndPoint = new IPEndPoint(ipAddressPort);
            while (
tries == && !Connection.Connected)
            {
                try
                {
                    
Connection.BeginConnect(ipEndPoint, new AsyncCallback(AsyncConnect), null);
                if (
Connection.Connected)
                {
                    return 
true;
                }
                }
                catch
                {
                    
System.Threading.Thread.Sleep(20000);
                }
            }
            return 
false;
        } 
Edit : i have done it after editing my code to ...

PHP Code:
public bool Connect(string IPint Port)
        {
            
int tries 0;
            
IPAddress ipAddress IPAddress.Parse(IP);
            
IPEndPoint ipEndPoint = new IPEndPoint(ipAddressPort);
            while (
tries == && !Connection.Connected)
            {
                try
                {
                    
HashSocket.Connect(ipEndPoint);
                    if (
HashSocket.Connected)
                    {
                        
Connection.BeginConnect(ipEndPoint, new AsyncCallback(AsyncConnect), null);
                        return 
true;
                        if (
Connection.Connected)
                        {
                            return 
true;
                        }
                    }
                }
                catch
                {
                    
System.Threading.Thread.Sleep(20000);
                }
            }
            return 
false;
        } 
it's works for me , thanks anyway...
abdeen is offline  
Old 10/09/2014, 18:50   #2
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
PHP Code:
TcpClient tcpclnt = new TcpClient();
    
try
{
        
tcpclnt.Connect("172.21.5.99",9958);
}
catch
{
//Server Offline

Xio. is offline  
Old 10/12/2014, 07:45   #3
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
Quote:
Originally Posted by Xio. View Post
PHP Code:
TcpClient tcpclnt = new TcpClient();
    
try
{
        
tcpclnt.Connect("172.21.5.99",9958);
}
catch
{
//Server Offline

Code:
static bool TryConnect(this Socket soc, IPEndPoint ipe) {
	try {
		soc.Connect(ipe);
		return true;
	} catch { return false; }
}
Code:
if (soc.TryConnect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9988))) {
    // use soc as client socket ...
}
else {
    // soc did not connect ....
}
Super Aids is offline  
Old 10/18/2014, 00:38   #4
 
abdeen's Avatar
 
elite*gold: 0
Join Date: Mar 2010
Posts: 475
Received Thanks: 15
Quote:
Originally Posted by Super Aids View Post
Code:
static bool TryConnect(this Socket soc, IPEndPoint ipe) {
	try {
		soc.Connect(ipe);
		return true;
	} catch { return false; }
}
Code:
if (soc.TryConnect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9988))) {
    // use soc as client socket ...
}
else {
    // soc did not connect ....
}
i want it keep trying till server socket is open and client connected !!
abdeen is offline  
Old 10/20/2014, 14:19   #5
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
So put it in a loop, gosh...
Xio. is offline  
Old 10/21/2014, 09:02   #6
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
Jesus ******* christ.
Code:
while (!soc.TryConnect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9988))) {
    System.Threading.Thread.Sleep(2000);
}
// use soc as client socket ...
Super Aids is offline  
Reply


Similar Threads Similar Threads
Editing Conquer Server Socket [ creating new client ]
04/21/2014 - CO2 Private Server - 11 Replies
Hello Epvp members , as title say i am editing conquer server socket to make it conquer client socket , actually i tried it many times but fails , spent more time on that , well ,, here is my idea.. Server and client each one have 2 sockets... Login Socket , Game Socket Server socket working very well , but i need to edit it to work with the client , just receiving and sending data , bytes and packets.. and don`t listen for incoming connections ... as i said i spent long time on this i...
Check your SERVER OPEN SSL BUG
04/08/2014 - Metin2 Private Server - 1 Replies
Der GAU für Verschlüsselung im Web: Horror-Bug in OpenSSL | heise online
Server Masters.. Let's Open Silkroad from Begin (KSRO 60CAP OPEN BETA CLIENT)
01/11/2014 - SRO Private Server - 2 Replies
http://kr.stdn.joymax.com/property/silkroad/SRO_OP EN.EXE Let's open this client.. Let's see and play first Silkroad. Zeteris Projects: Source Code
How to change the server status from Check to Open?
10/13/2011 - SRO Private Server - 1 Replies
as the title says ... only 1 answer should be enough!
How can i make server Check-Open
09/15/2011 - SRO Private Server - 3 Replies
My server is in check status now.How can i make easy please help me :S:S:S



All times are GMT +1. The time now is 20:01.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.