connAttempt() private method

private connAttempt ( String node, bool incoming, Object info ) : void
node String
incoming bool
info Object
return void
コード例 #1
0
            public override void run()
            {
                TcpClient           newsock = null;
                OtpCookedConnection conn    = null;

                node.localStatus(node.Node, true, null);

                accept_loop : while (!done)
                {
                    conn = null;

                    try
                    {
                        newsock = sock.AcceptTcpClient();
                    }
                    catch (Exception e)
                    {
                        // Problem in java1.2.2: accept throws SocketException
                        // when socket is closed. This will happen when
                        // acceptor.quit()
                        // is called. acceptor.quit() will call localStatus(...), so
                        // we have to check if that's where we come from.
                        if (!done)
                        {
                            node.localStatus(node.Node, false, e);
                        }
                        goto accept_loop;
                    }

                    try
                    {
                        lock (node.Connections)
                        {
                            conn = new OtpCookedConnection(node, new BufferedTcpClient(newsock));
                            conn.setFlags(node.Flags);
                            node.addConnection(conn);
                        }
                    }
                    catch (OtpAuthException e)
                    {
                        if (conn != null && conn.Name != null)
                        {
                            node.connAttempt(conn.Name, true, e);
                        }
                        else
                        {
                            node.connAttempt("unknown", true, e);
                        }
                        closeSock(newsock);
                    }
                    catch (IOException e)
                    {
                        if (conn != null && conn.Name != null)
                        {
                            node.connAttempt(conn.Name, true, e);
                        }
                        else
                        {
                            node.connAttempt("unknown", true, e);
                        }
                        closeSock(newsock);
                    }
                    catch (Exception e)
                    {
                        closeSock(newsock);
                        closeSock(sock);
                        node.localStatus(node.Node, false, e);
                        goto accept_loop;
                    }
                } // while

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