Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "check":
- if (parameters.Length > 1)
- {
- String s = "Server is ";
- IPHostEntry entry = Dns.GetHostEntry(parameters[0]);
- AutoResetEvent connectDone = new AutoResetEvent(false);
- TcpClient c = new TcpClient();
- c.BeginConnect(
- entry.AddressList[0], int.Parse(parameters[1]),
- new AsyncCallback(
- delegate(IAsyncResult ar)
- {
- try
- {
- c.EndConnect(ar);
- connectDone.Set();
- }
- catch (Exception e)
- {
- client.LocalUser.SendMessage(target.Name, "Exception: " + e.Message);
- }
- }
- ), c
- );
- if (!connectDone.WaitOne(2000))
- {
- c.Close();
- s += "down";
- }
- else
- {
- c.Close();
- s += "up";
- }
- client.LocalUser.SendMessage(target, s);
- }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement