try {
_multicastSocket = new MulticastSocket(
newSocketNumber);
} catch (Exception ex) {
throw new InternalErrorException(this, ex,
"Couldn't open new socket number "
+ newSocketNumber);
}
if (_address != null) {
try {
_multicastSocket.joinGroup(_address);
} catch (IOException exp) {
throw new IllegalActionException(
"can't join the multicast group"
+ exp);
}
}
}
} else if ((_socket != null)
&& (newSocketNumber != _socket.getLocalPort())) {
synchronized (_syncSocket) {
if (_inReceive) {
// Wait for receive to finish, if it
// does not take very long that is.
try {
_syncSocket.wait(444);
} catch (InterruptedException ex) {
throw new IllegalActionException(this, ex,
"Interrupted while waiting");
}
// Either I've been notified that receive()
// has completed, or the timeout has occurred.
// It does not matter which. Either way I am
// now ready to close and re-open the socket.
}
_socket.close();
try {
_socket = new DatagramSocket(newSocketNumber);
} catch (SocketException ex) {
throw new InternalErrorException(this, ex,
"Couldn't open new socket number "
+ newSocketNumber);
}
}
}