+ stack.getPort(this.getTransport()),
+ this.myPort,
    public void run() {                while (true) {            // Create a new string message parser to parse the list of messages.            // This is a huge performance hit -- need to optimize by pre-create            // parser when one is needed....            if (myParser == null) {                myParser = new StringMsgParser();                myParser.setParseExceptionListener(this);            }            // messages that we write out to him.            DatagramPacket packet;                        if (stack.threadPoolSize != -1) {//ifdef SIMULATION/*                                ((UDPMessageProcessor)messageProcessor).                                messageQueueShadow.enterCriticalSection();//else*/                synchronized (                ((UDPMessageProcessor) messageProcessor).messageQueue)//endif//                {                    while (((UDPMessageProcessor) messageProcessor)                    .messageQueue                    .isEmpty()) {                        // Check to see if we need to exit.                        if (!((UDPMessageProcessor) messageProcessor)                        .isRunning)                            return;                        try {//ifdef SIMULATION/*                                                        ((UDPMessageProcessor)messageProcessor).                                                                        messageQueueShadow.doWait();//else */                            ((UDPMessageProcessor) messageProcessor)                            .messageQueue.wait();//endif//                        } catch (InterruptedException ex) {                            if (!((UDPMessageProcessor) messageProcessor)                            .isRunning)                                return;                        }                    }                    packet =                    (DatagramPacket)                    ((UDPMessageProcessor) messageProcessor)                    .messageQueue                    .removeFirst();                                    }//ifdef SIMULATION/*                                ((UDPMessageProcessor)messageProcessor).                                messageQueueShadow.leaveCriticalSection();//endif*/                this.incomingPacket = packet;            } else {                packet = this.incomingPacket;            }                        this.peerAddress = packet.getAddress();            int packetLength = packet.getLength();            // Read bytes and put it in a eueue.            byte[] bytes = packet.getData();            byte[] msgBytes = new byte[packetLength];            System.arraycopy(bytes, 0, msgBytes, 0, packetLength);                        // Do debug logging.            if (LogWriter.needsLogging) {                this.stack.logWriter.logMessage(                "UDPMessageChannel: peerAddress = "                + peerAddress.getHostAddress()                + "/"                + packet.getPort());                this.stack.logWriter.logMessage("Length = " + packetLength);                String msgString = new String(msgBytes, 0, packetLength);                this.stack.logWriter.logMessage(msgString);            }                        SIPMessage[] sipMessages = null;            SIPMessage sipMessage = null;            try {                //ifdef SIMULATION/*                               this.receptionTime = SimSystem.currentTimeMillis();                                // local delay for processing message.                                SimSystem.hold(this.stack.stackProcessingTime);//else */                this.receptionTime = System.currentTimeMillis();//endif//                                sipMessage = myParser.parseSIPMessage(msgBytes);                myParser = null;            } catch (ParseException ex) {                myParser = null; // let go of the parser reference.                if (LogWriter.needsLogging) {                    this.stack.logWriter.logMessage(                    "Rejecting message !  " + new String(msgBytes));                    this.stack.logWriter.logMessage(                    "error message " + ex.getMessage());                    this.stack.logWriter.logException(ex);                }                stack.logBadMessage(new String(msgBytes));                if (stack.threadPoolSize == -1)                    return;                else                    continue;            }            // No parse exception but null message - reject it and            // march on (or return). Bug report from Peter Parnes.            // exit this message processor if the message did not parse.                        if (sipMessage == null) {                if (LogWriter.needsLogging) {                    this.stack.logWriter.logMessage(                    "Rejecting message !  " + new String(msgBytes));                    this.stack.logWriter.logMessage("Null message parsed.");                }                if (stack.threadPoolSize == -1)                    return;                else                    continue;            }            ViaList viaList = sipMessage.getViaHeaders();            // Check for the required headers.            if (sipMessage.getFrom() == null            || //sipMessage.getFrom().getTag() == null  ||            sipMessage.getTo()            == null            || sipMessage.getCallId() == null            || sipMessage.getCSeq() == null            || sipMessage.getViaHeaders() == null) {                String badmsg = new String(msgBytes);                if (LogWriter.needsLogging) {                    this.stack.logWriter.logMessage("bad message " + badmsg);                    this.stack.logWriter.logMessage(                    ">>> Dropped Bad Msg "                    + "From = "                    + sipMessage.getFrom()                    + "To = "                    + sipMessage.getTo()                    + "CallId = "                    + sipMessage.getCallId()                    + "CSeq = "                    + sipMessage.getCSeq()                    + "Via = "                    + sipMessage.getViaHeaders());                }                                stack.logBadMessage(badmsg);                if (stack.threadPoolSize == -1)                    return;                else                    continue;            }            // For a request first via header tells where the message            // is coming from.            // For response, just get the port from the packet.            if (sipMessage instanceof SIPRequest) {                Via v = (Via) viaList.first();                if (v.hasPort()) {                    if (sipMessage instanceof SIPRequest) {                        this.peerPort = v.getPort();                    }                } else                    this.peerPort = SIPMessageStack.DEFAULT_PORT;                this.peerProtocol = v.getTransport();                try {                    this.peerAddress = packet.getAddress();                    // Check to see if the received parameter matches                    // the peer address and tag it appropriately.                    // Bug fix by viswashanti.kadiyala@antepo.com                    if (!v                    .getSentBy()                    .getInetAddress()                    .equals(this.peerAddress))                        v.setParameter(                        Via.RECEIVED,                        this.peerAddress.getHostName());                                        // this.peerAddress = v.getSentBy().getInetAddress();                } catch (java.net.UnknownHostException ex) {                    // Could not resolve the sender address.                    if (stack                    .serverLog                    .needsLogging(ServerLog.TRACE_MESSAGES)) {                        this.stack.serverLog.logMessage(                        sipMessage,                        this.getViaHost() + ":" + this.getViaPort(),                        stack.getHostAddress()                        + ":"                        + stack.getPort(this.getTransport()),                        "Dropped -- "                        + "Could not resolve VIA header address!",                        false);                    }                    if (LogWriter.needsLogging) {                        this.stack.logWriter.logMessage(                        "Rejecting message -- "                        + "could not resolve Via Address");                    }                                        continue;                } catch (java.text.ParseException ex1) {                    InternalErrorHandler.handleException(ex1);                }                            }                        if (sipMessage instanceof SIPRequest) {                SIPRequest sipRequest = (SIPRequest) sipMessage;                                // This is a request - process it.                ServerRequestInterface sipServerRequest =                stack.newSIPServerRequest(sipRequest, this);                // Drop it if there is no request returned                if (sipServerRequest == null) {                    if (LogWriter.needsLogging) {                        this.stack.logWriter.logMessage(                        "Null request interface returned");                    }                    continue;                }                if (LogWriter.needsLogging)                    this.stack.logWriter.logMessage(                    "About to process "                    + sipRequest.getFirstLine()                    + "/"                    + sipServerRequest);                sipServerRequest.processRequest(sipRequest, this);                if (LogWriter.needsLogging)                    this.stack.logWriter.logMessage(                    "Done processing "                    + sipRequest.getFirstLine()                    + "/"                    + sipServerRequest);                                // So far so good -- we will commit this message if                // all processing is OK.                if (stack                .serverLog                .needsLogging(ServerLog.TRACE_MESSAGES)) {                    if (sipServerRequest.getProcessingInfo() == null) {                        this.stack.serverLog.logMessage(                        sipMessage,                        sipRequest.getViaHost()                        + ":"                        + sipRequest.getViaPort(),                        stack.getHostAddress()                        + ":"                        + stack.getPort(this.getTransport()),                        false,                        new Long(receptionTime).toString());                    } else {                        this.stack.serverLog.logMessage(                        sipMessage,                        sipRequest.getViaHost()                        + ":"                        + sipRequest.getViaPort(),                        stack.getHostAddress()                        + ":"                        + stack.getPort(this.getTransport()),                        sipServerRequest.getProcessingInfo(),                        false,                        new Long(receptionTime).toString());                    }                }            } else {                // Handle a SIP Reply message.                SIPResponse sipResponse = (SIPResponse) sipMessage;                ServerResponseInterface sipServerResponse =                stack.newSIPServerResponse(sipResponse, this);                if (sipServerResponse != null) {                    sipServerResponse.processResponse(sipResponse, this);                    // Normal processing of message.                } else {                    if (LogWriter.needsLogging) {                        this.stack.logWriter.logMessage(                        "null sipServerResponse!");                    }                }                            }            //((UDPMessageProcessor) messageProcessor).useCount--;            if (stack.threadPoolSize == -1) {                return;            }        }    }