public void returnAcceptedClient(OCNetworkClient toRet) { lock (slockcl) { if (cExists && toRet == acceptedClient) { toRet.shutdown(); toRet.close(); toRet = null; cExists = false; } } }
public OCNetworkClient getAcceptedClient() { OCNetworkClient toret = null; lock (slockcl) { if (cWaiting && acceptedClient != null) { cExists = true; cWaiting = false; toret = acceptedClient; } } return(toret); }
private void run() { while (listening) { while (cExists) { try { Thread.Sleep(100); } catch (ThreadInterruptedException e) { break; } } try { Socket sa = sSock.Accept(); if (shouldAccept(sa)) { sa.ReceiveBufferSize = Int16.MaxValue; sa.SendBufferSize = Int16.MaxValue; sa.ReceiveTimeout = 5000; sa.SendTimeout = 5000; acceptedClient = new OCNetworkClient(sa); cWaiting = true; while (cWaiting) { try { Thread.Sleep(100); } catch (ThreadInterruptedException e) { break; } } } else { try { sa.Shutdown(SocketShutdown.Both); } catch (SocketException e) { } try { sa.Close(); } catch (SocketException e) { } sa = null; } } catch (SocketException e) { } } }