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 .
Edit : i have done it after editing my code to ...
it's works for me , thanks anyway...;)
PHP Code:
public bool Connect(string IP, int Port)
{
int tries = 0;
IPAddress ipAddress = IPAddress.Parse(IP);
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, Port);
while (tries == 0 && !Connection.Connected)
{
try
{
Connection.BeginConnect(ipEndPoint, new AsyncCallback(AsyncConnect), null);
if (Connection.Connected)
{
return true;
}
}
catch
{
System.Threading.Thread.Sleep(20000);
}
}
return false;
}
PHP Code:
public bool Connect(string IP, int Port)
{
int tries = 0;
IPAddress ipAddress = IPAddress.Parse(IP);
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, Port);
while (tries == 0 && !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;
}