return new JChannel(config);
}
protected static void makeUnique(Channel channel, int num) throws Exception {
ProtocolStack stack=channel.getProtocolStack();
TP transport=stack.getTransport();
InetAddress bind_addr=transport.getBindAddressAsInetAddress();
if(transport instanceof UDP) {
String mcast_addr=ResourceManager.getNextMulticastAddress();
short mcast_port=ResourceManager.getNextMulticastPort(bind_addr);
((UDP)transport).setMulticastAddress(InetAddress.getByName(mcast_addr));
((UDP)transport).setMulticastPort(mcast_port);
}
else if(transport instanceof BasicTCP) {
List<Short> ports=ResourceManager.getNextTcpPorts(bind_addr, num);
transport.setBindPort(ports.get(0));
transport.setPortRange(num);
Protocol ping=stack.findProtocol(TCPPING.class);
if(ping == null)
throw new IllegalStateException("TCP stack must consist of TCP:TCPPING - other config are not supported");
List<String> initial_hosts=new LinkedList<String>();
for(short port: ports) {