예제 #1
0
        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;
                            }
                        }
                    }
                }
            }
        }
예제 #2
0
파일: SCB.cs 프로젝트: zjusongjin/NTCPMSG
        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);
        }
예제 #3
0
        private void SendAcknowledgment(ApplicationProtocolHeader head)
        {
            _Logger.Debug("Sending header acknowledgment");

            try
            {
                WorkSocket.Send(head.WrapHeaderData());
            }
            catch (Exception)
            {
                _Logger.Error("Error sending header acknowledgment");
                CloseConnectionGracefully();
            }
        }