private void DataSent(IAsyncResult res) { try { if (!IsConnected()) { Disconnect(); return; } var sent = ((Socket)res.AsyncState).EndSend(res); if (sent < 0) { Sock.Shutdown(SocketShutdown.Both); Sock.Close(); return; } var data = new DataEventArgs(this, new byte[] { }, sent); OnDataSent(this, data); } catch (Exception ex) { #if DEBUG Console.WriteLine(ex.ToString()); #endif } }
public void Dispose(bool disposing) { if (Sock != null && Sock.Connected) { try { Sock.Shutdown(SocketShutdown.Both); Sock.Close(); Sock = null; } catch { } } }
public void Close(ESockerCloseType eType, int param, bool isPassiveClose) { bool result = false; if (SUCCESS(IsClosed)) { goto Exit1; } IsClosed = true; IsPassiveClosed = isPassiveClose; Sock.Shutdown(SocketShutdown.Send); result = LP.NetModule.EventMgr.PushTerminateEvent(this); if (LOG_ERROR(result)) { goto Exit0; } Exit1: Exit0: return; }
public void Close() { // Release the socket. Sock.Shutdown(SocketShutdown.Both); Sock.Close(); }