void Accept(IAsyncResult result) { if (Server.shuttingDown) { return; } Remote p = null; var begin = false; try { p = new Remote(); if (tries < 7) { if (tries < 5) { p.Socket = listen.EndAccept(result); new Thread(p.Start).Start(); listen.BeginAccept(Accept, null); begin = true; } else { new Thread(() => { Thread.Sleep(0x927c0); //10 mins Command.all.Find("remote").Use(null, "resettry"); }).Start(); } } } catch (SocketException) { if (p != null) { p.Disconnect(); } if (begin) { return; } listen.BeginAccept(Accept, null); } catch (Exception e) { Server.s.Log(e.Message); Server.s.Log(e.StackTrace); if (p != null) { p.Disconnect(); } if (begin) { return; } listen.BeginAccept(Accept, null); } }
static void Receive(IAsyncResult result) { Remote p = (Remote)result.AsyncState; if (p.Upcast || p.Socket == null) { return; } try { int length = p.Socket.EndReceive(result); if (length == 0) { p.Disconnect(); return; } byte[] b = new byte[p._bu.Length + length]; Buffer.BlockCopy(p._bu, 0, b, 0, p._bu.Length); Buffer.BlockCopy(p._tbu, 0, b, p._bu.Length, length); p._bu = p.HandleMessage(b); p.Socket.BeginReceive(p._tbu, 0, p._tbu.Length, SocketFlags.None, new AsyncCallback(Receive), p); } catch (SocketException) { p.Disconnect(); } catch (Exception e) { p.Disconnect(); Server.ErrorLog(e); } }
void Accept(IAsyncResult result) { if (Server.shuttingDown == false) { Remote p = null; bool begin = false; try { p = new Remote(); p.socket = listen.EndAccept(result); new Thread(new ThreadStart(p.Start)).Start(); listen.BeginAccept(new AsyncCallback(Accept), null); begin = true; } catch (SocketException) { if (p != null) p.Disconnect(); if (!begin) listen.BeginAccept(new AsyncCallback(Accept), null); } catch (Exception e) { Server.s.Log(e.Message); Server.s.Log(e.StackTrace); if (p != null) p.Disconnect(); if (!begin) listen.BeginAccept(new AsyncCallback(Accept), null); } } }
void Accept(IAsyncResult result) { if (Server.shuttingDown) return; Remote p = null; var begin = false; try { p = new Remote(); if (tries < 7) { if (tries < 5) { p.Socket = listen.EndAccept(result); new Thread(p.Start).Start(); listen.BeginAccept(Accept, null); begin = true; } else { new Thread(() => { Thread.Sleep(0x927c0); //10 mins Command.all.Find("remote").Use(null, "resettry"); }).Start(); } } } catch (SocketException) { if (p != null) p.Disconnect(); if (begin) return; listen.BeginAccept(Accept, null); } catch (Exception e) { Server.s.Log(e.Message); Server.s.Log(e.StackTrace); if (p != null) p.Disconnect(); if (begin) return; listen.BeginAccept(Accept, null); } }