コード例 #1
0
        public void ReceiveRepeat()
        {
            try
            {
                this.IsWaitTcpReceive = true;
                while (this.IsWaitTcpReceive && !this.disposed)
                {
                    var state = new CtkTcpSocketStateEventArgs()
                    {
                        sender     = this,
                        workSocket = this.WorkSocket,//Actively socket 為連線的socket本身
                        buffer     = new byte[1518]
                    };

                    state.dataSize = state.workSocket.Receive(state.buffer, 0, state.buffer.Length, SocketFlags.None);
                    if (state.dataSize == 0)
                    {
                        break;
                    }
                    this.OnReceiveData(state);
                }
            }
            finally
            {
                if (this.ConnSocket != this.WorkSocket)
                {
                    CtkNetUtil.DisposeSocket(this.WorkSocket);
                }
            }
        }
コード例 #2
0
        public void OnReceiveData(CtkTcpSocketStateEventArgs state)
        {
            if (this.eventReceiveData == null)
            {
                return;
            }

            this.eventReceiveData(this, state);
        }