예제 #1
0
        /// <summary>
        /// 设置基本配置
        /// </summary>
        /// <param name="receiveBufferSize">用于每个套接字I/O操作的缓冲区大小(接收端)</param>
        public TcpPushClient(int receiveBufferSize)
        {
            Thread thread = new Thread(new ThreadStart(() =>
            {
                tcpClients            = new TcpClients(receiveBufferSize);
                tcpClients.OnConnect += TcpServer_eventactionConnect;
                tcpClients.OnReceive += TcpServer_eventactionReceive;
                tcpClients.OnSend    += TcpClients_OnSend;
                tcpClients.OnClose   += TcpServer_eventClose;
            }));

            thread.IsBackground = true;
            thread.Start();
        }
예제 #2
0
        /// <summary>
        /// 设置基本配置
        /// </summary>
        /// <param name="receiveBufferSize">用于每个套接字I/O操作的缓冲区大小(接收端)</param>
        /// <param name="headerFlag">包头标记范围0~1023(0x3FF),当包头标识等于0时,不校验包头</param>
        public TcpPackClient(int receiveBufferSize, uint headerFlag)
        {
            if (headerFlag < 0 || headerFlag > 1023)
            {
                headerFlag = 0;
            }
            this.headerFlag = headerFlag;
            Thread thread = new Thread(new ThreadStart(() =>
            {
                queue                 = new List <byte>();
                tcpClients            = new TcpClients(receiveBufferSize);
                tcpClients.OnConnect += TcpServer_eventactionConnect;
                tcpClients.OnReceive += TcpServer_eventactionReceive;
                tcpClients.OnClose   += TcpServer_eventClose;
            }));

            thread.IsBackground = true;
            thread.Start();
        }