private void ProcessBuffers() { if (!WorkSocket.Connected) { Buffer = null; return; } if (Buffer != null) { lock (Buffer) { if (Buffer.Position > 0) { var payload = Buffer.ToBuffer(); WorkSocket.Send(payload, 0, payload.Length, System.Net.Sockets.SocketFlags.None, out var error); { if (error != System.Net.Sockets.SocketError.SocketError) { Buffer.Position = 0; } } } } } }
internal void AsyncSend(byte[] buf) { //while (BufferLength > 1024 * 1024) //{ // System.Threading.Thread.Sleep(1); //} //IncBufferLength(buf.Length); //WorkSocket.BeginSend(buf, 0, buf.Length, SocketFlags.None, // new AsyncCallback(Async_Send), WorkSocket); WorkSocket.Send(buf, SocketFlags.None); }
private void SendAcknowledgment(ApplicationProtocolHeader head) { _Logger.Debug("Sending header acknowledgment"); try { WorkSocket.Send(head.WrapHeaderData()); } catch (Exception) { _Logger.Error("Error sending header acknowledgment"); CloseConnectionGracefully(); } }