public static void TryReceive(ClientWrapper wrapper) { wrapper.LastReceiveCall = Time32.Now; if (!wrapper.isValid()) { return; } try { bool poll = wrapper.Socket.Poll(0, SelectMode.SelectRead); int available = wrapper.Socket.Available; if (available > 0) { wrapper.doReceive(available); } else if (poll) { wrapper.Server.InvokeDisconnect(wrapper); } } catch (SocketException) { wrapper.Server.InvokeDisconnect(wrapper); } }
public static void TrySend(ClientWrapper wrapper) { if (!wrapper.isValid()) { return; } byte[] buffer; while (wrapper.TryDequeueSend(out buffer)) { try { wrapper.Socket.Send(buffer); //wrapper.Socket.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, endSend, wrapper); } catch { wrapper.Server.InvokeDisconnect(wrapper); } } }