示例#1
0
文件: OtpNode.cs 项目: trompa/jungerl
            public void Start()
            {
                System.Net.Sockets.TcpClient newsock = null;
                OtpCookedConnection          conn    = null;

                a_node.localStatus(a_node._node, true, null);

                while (!a_done)
                {
                    conn = null;

                    try
                    {
                        newsock = a_sock.AcceptTcpClient();
                    }
                    catch (System.Exception e)
                    {
                        a_node.localStatus(a_node._node, false, e);
                        goto accept_loop_brk;
                    }

                    try
                    {
                        lock (a_node.connections)
                        {
                            conn = new OtpCookedConnection(a_node, newsock);
                            a_node.addConnection(conn);
                        }
                    }
                    catch (OtpAuthException e)
                    {
                        if (conn != null && conn.name != null)
                        {
                            a_node.connAttempt(conn.name, true, e);
                        }
                        else
                        {
                            a_node.connAttempt("unknown", true, e);
                        }
                        closeSock(newsock);
                    }
                    catch (System.IO.IOException e)
                    {
                        if (conn != null && conn.name != null)
                        {
                            a_node.connAttempt(conn.name, true, e);
                        }
                        else
                        {
                            a_node.connAttempt("unknown", true, e);
                        }
                        closeSock(newsock);
                    }
                    catch (System.Exception e)
                    {
                        closeSock(newsock);
                        closeSock(a_sock);
                        a_node.localStatus(a_node._node, false, e);
                        goto accept_loop_brk;
                    }
                }
                accept_loop_brk :;
                // while

                // if we have exited loop we must do this too
                unPublishPort();
            }