Esempio n. 1
0
        //------------------------------------------------------------------------------------------------------------------------
#if NETFX
        void PortListenerEntryPoint()
        {
            try
            {
                //start listening
                sock?.Listen(50);

                //heartbeat
                while (_IsRunning)
                {
                    //we need to stop?
                    if (sock == null)
                    {
                        break;
                    }

                    try
                    {
                        //accept new connection
                        var newsocket = sock.Accept();

                        //handlew new connection
                        if (newsocket != null)
                        {
                            HandleNewConnection(newsocket);
                        }
                    }
                    catch (Exception ex) { DebugEx.TraceErrorException(ex); }
                }
            }
            catch (Exception ex)
            {
                DebugEx.Assert(ex, "YPChannel server heartbeat error");
            }

            //inform for heartbeat end
            DebugEx.TraceLog("YPChannel server heartbeat finished");
        }
Esempio n. 2
0
        //------------------------------------------------------------------------------------------------------------------------
#if NETFX
        void PortListenerEntryPoint()
        {
            try
            {
                //start listening
                sock?.Listen(10);

                //heartbeat
                while (_IsRunning)
                {
                    //listen
                    Socket newsocket = null;

                    //we need to stop?
                    var __sock = sock;  //keep a local copy
                    if (__sock == null)
                    {
                        break;
                    }

                    //accept and get new socket
                    try { newsocket = __sock.Accept(); }
                    catch (Exception ex) { DebugEx.TraceError(ex, "YPServer sock.Accept() exception"); continue; }

                    //handlew new connection
                    HandleNewConnection(newsocket);
                }
            }
            catch (Exception ex)
            {
                DebugEx.Assert(ex, "YPChannel server heartbeat error");
            }

            //inform for heartbeat end
            DebugEx.TraceLog("YPChannel server heartbeat finished");
        }