private void Send_Completion(object sender, SocketAsyncEventArgs e) { Send_Process(e); if (m_Disposing) { return; } if (m_CoalesceSleep >= 0) { Thread.Sleep(m_CoalesceSleep); } SendQueue.Gram gram; lock (m_SendQueue) { gram = m_SendQueue.Dequeue(); if (gram == null && m_SendQueue.IsFlushReady) { gram = m_SendQueue.CheckFlushReady(); } } if (gram != null) { m_SendEventArgs.SetBuffer(gram.Buffer, 0, gram.Length); Send_Start(); } }
private void OnSend(IAsyncResult asyncResult) { var s = (Socket)asyncResult.AsyncState; try { var bytes = s.EndSend(asyncResult); if (bytes <= 0) { Dispose(false); return; } m_NextCheckActivity = Core.TickCount + 90000; if (m_CoalesceSleep >= 0) { Thread.Sleep(m_CoalesceSleep); } SendQueue.Gram gram; lock (m_SendQueue) { gram = m_SendQueue.Dequeue(); if (gram == null && m_SendQueue.IsFlushReady) { gram = m_SendQueue.CheckFlushReady(); } } if (gram != null) { try { s.BeginSend(gram.Buffer, 0, gram.Length, SocketFlags.None, m_OnSend, s); } catch (Exception ex) { TraceException(ex); Dispose(false); } } else { lock (_SendLock) { _Sending = false; } } } catch (Exception) { Dispose(false); } }
public bool Flush() { if (m_Socket == null || !m_SendQueue.IsFlushReady) { return(false); } SendQueue.Gram gram; lock (m_SendQueue) { gram = m_SendQueue.CheckFlushReady(); } if (gram != null) { try { m_Socket.BeginSend(gram.Buffer, 0, gram.Length, SocketFlags.None, m_OnSend, m_Socket); return(true); } catch (Exception ex) { TraceException(ex); Dispose(false); } } return(false); }
public bool Flush() { if (m_Socket == null || !m_SendQueue.IsFlushReady) { return(false); } int length = 0; byte[] buffer; lock (m_SendQueue) buffer = m_SendQueue.CheckFlushReady(ref length); if (buffer != null) { try { m_Socket.BeginSend(buffer, 0, length, SocketFlags.None, m_OnSend, null); m_Sending = true; //m_Socket.Send( buffer, 0, length, SocketFlags.None ); return(true); //Console.WriteLine( "Flush: {0}: Begin send of {1} bytes", this, length ); } catch // ( Exception ex ) { //Console.WriteLine(ex); Dispose(false); } } return(false); }
public bool Flush() { if (m_Socket == null || !m_SendQueue.IsFlushReady) { return(false); } int length = 0; byte[] buffer; lock (m_SendQueue) buffer = m_SendQueue.CheckFlushReady(ref length); if (buffer != null) { try { m_Socket.BeginSend(buffer, 0, length, SocketFlags.None, OnSend, null); m_Sending = true; return(true); } catch (Exception ex) { TraceException(ex); Dispose(false); } } return(false); }
public bool Flush() { if (m_Socket == null || !m_SendQueue.IsFlushReady) { return(false); } SendQueue.Gram gram; lock ( m_SendQueue ) { gram = m_SendQueue.CheckFlushReady(); } if (gram != null) { m_SendEventArgs.SetBuffer(gram.Buffer, 0, gram.Length); Send_Start(); } return(false); }