}
DatagramPacket reply = new DatagramPacket(msg, msg.length, peerAddress,
peerPort);
try {
DatagramSocket sock;
boolean created = false;
if (sipStack.udpFlag) {
// Use the socket from the message processor (for firewall
// support use the same socket as the message processor
// socket -- feature request # 18 from java.net). This also
// makes the whole thing run faster!
sock = ((UDPMessageProcessor) messageProcessor).sock;
// Bind the socket to the stack address in case there
// are multiple interfaces on the machine (feature reqeust
// by Will Scullin) 0 binds to an ephemeral port.
// sock = new DatagramSocket(0,sipStack.stackInetAddress);
} else {
// bind to any interface and port.
sock = new DatagramSocket();
created = true;
}
sock.send(reply);
if (created)
sock.close();
} catch (IOException ex) {
throw ex;
} catch (Exception ex) {
InternalErrorHandler.handleException(ex);
}