Пример #1
0
 private void THSocketConnectWait()
 {
     while (mListen)
     {
         WClient sclient    = new WClient(tcpServer.AcceptSocket());
         Thread  thWaitData = new Thread(new ParameterizedThreadStart(THSocketDataWait));
         thWaitData.Start(sclient);
     }
 }
Пример #2
0
        private void THSocketDataWait(object osclient)
        {
            WClient sclient = (WClient)osclient;

            while (sclient.Soket.Connected)
            {
                byte[] dataArray = new byte[8192];
                int    dataCount = sclient.Soket.Receive(dataArray);

                string dataStr = Encoding.Unicode.GetString(dataArray);
                if (dataCount > 0)
                {
                    if (ReceiveData != null)
                    {
                        ReceiveData(sclient, dataArray);
                    }
                }

                if (dataCount == 0)
                {
                    break;
                }
            }
        }