Inheritance: ISocket
Example #1
0
        /// <summary>
        /// Main body of the write thread.  Blocks until the lock on _syncRoot
        /// has been pulsed and then pops the top heap item off the queue and
        /// sends it to the connected client.
        /// </summary>
        protected void WriteThread()
        {
            HeapItem item;

            threadCancelled = false;
            bool exit = false;

            while (true)
            {
                if (threadCancelled == true)
                {
                    break;
                }

                lock (_syncRoot)
                {
                    while (sendQueue.Count == 0 && threadCancelled == false)
                    {
                        /*
                         * Will wait without timeout until it is pulsed
                         */
                        if (Monitor.Wait(_syncRoot, 1000) == false)
                        {
                            TcpSocket sock = client.Socket as TcpSocket;

                            try
                            {
                                if (sock._connection.Client.Poll(1000, SelectMode.SelectRead) && sock._connection.Available == 0)
                                {
                                    //Trace.WriteLine($"{client.Id} has a dead socket!");
                                    exit = true;
                                    break;
                                }
                            }
                            catch
                            {
                                //Trace.WriteLine($"{client.Id} has a dead socket!");
                                exit = true;
                                break;
                            }
                        }
                    }

                    if (threadCancelled || exit)
                    {
                        Netplay.Clients[client.Id].PendingTermination = true;
                        break;
                    }

                    item = sendQueue.Dequeue();
                }

                SendHeapItem(item);
            }

            hasWriteThread = false;
        }
Example #2
0
 private void ListenLoop()
 {
     while (_isListening && !Netplay.Disconnect)
     {
         try
         {
             ISocket socket = new TcpSocket(_listener.AcceptTcpClient());
             Console.WriteLine(Language.GetTextValue("Net.ClientConnecting", socket.GetRemoteAddress()));
             _listenerCallback(socket);
         }
         catch (Exception)
         {
         }
     }
     _listener.Stop();
 }
Example #3
0
 private void ListenLoop(object unused)
 {
     while (_isListening && !Netplay.disconnect)
     {
         try
         {
             ISocket socket = new TcpSocket(_listener.AcceptTcpClient());
             Console.WriteLine(string.Concat(socket.GetRemoteAddress(), " is connecting..."));
             _listenerCallback(socket);
         }
         catch (Exception)
         {
         }
     }
     _listener.Stop();
 }
Example #4
0
        private void ListenLoop(object unused)
        {
            while (this._isListening && !Netplay.disconnect)
            {
                try
                {
                    ISocket tcpSocket = new TcpSocket(this._listener.AcceptTcpClient());
                    this._listenerCallback(tcpSocket);
                }
                catch (Exception ex)
                {
#if DEBUG
                    Console.WriteLine(ex);
                    System.Diagnostics.Debugger.Break();
#endif
                }
            }
            this._listener.Stop();
        }
Example #5
0
        private void ListenLoop(object unused)
        {
            while (this._isListening && !Netplay.disconnect)
            {
                try
                {
                    ISocket tcpSocket = new TcpSocket(this._listener.AcceptTcpClient());
                    this._listenerCallback(tcpSocket);
                }
                catch (Exception ex)
                {
            #if DEBUG
                    Console.WriteLine(ex);
                    System.Diagnostics.Debugger.Break();

            #endif
                }
            }
            this._listener.Stop();
        }
		private void ListenLoop(object unused)
		{
			while (this._isListening && !Netplay.disconnect)
			{
				try
				{
					ISocket socket = new TcpSocket(this._listener.AcceptTcpClient());
					Console.WriteLine(socket.GetRemoteAddress() + " is connecting...");
					this._listenerCallback(socket);
				}
				catch (Exception)
				{
				}
			}
			this._listener.Stop();
		}