private void WriteCallback(IAsyncResult ar) { BeginSendDelegate asyncState = (BeginSendDelegate)ar.AsyncState; if ((this.m_socket == null) || (this.m_sslStream == null)) { if (asyncState != null) { asyncState(false); } } else { try { this.m_sslStream.EndWrite(ar); this.m_canSend = true; if (asyncState != null) { asyncState(true); } } catch (Exception exception) { object[] args = new object[] { exception }; s_log.LogWarning("Exception while trying to call EndWrite. {0}", args); if (asyncState != null) { asyncState(false); } } } }
public void BeginSend(byte[] bytes, BeginSendDelegate sendDelegate) { try { if (this.m_sslStream == null) { throw new NullReferenceException("m_sslStream is null!"); } this.m_canSend = false; this.m_sslStream.BeginWrite(bytes, 0, bytes.Length, new AsyncCallback(this.WriteCallback), sendDelegate); } catch (Exception exception) { object[] args = new object[] { exception }; s_log.LogWarning("Exception while trying to call BeginWrite. {0}", args); if (sendDelegate != null) { sendDelegate(false); } } }