static final String BIND_ADDR = "192.168.1.101" ;
public static void main(String[] args) throws Exception {
JChannel channel = new JChannel(false);
ProtocolStack stack = new ProtocolStack();
channel.setProtocolStack(stack);
stack.addProtocols(new UDP().setValue("bind_addr", InetAddress.getByName(BIND_ADDR)))
.addProtocol(new PING())
.addProtocol(new MERGE2())
.addProtocol(new FD_SOCK())
.addProtocol(new FD_ALL().setValue("timeout", 12000).setValue("interval", 3000))
.addProtocol(new VERIFY_SUSPECT()).addProtocol(new BARRIER())
.addProtocol(new NAKACK()).addProtocol(new UNICAST2())
.addProtocol(new STABLE()).addProtocol(new GMS())
.addProtocol(new UFC()).addProtocol(new MFC())
.addProtocol(new FRAG2());
stack.init();
channel.setReceiver(new ReceiverAdapter(){
public void receive(Message msg) {
Address sender=msg.getSrc();
System.out.println(msg.getObject() + " [" + sender + "]");
}
public void viewAccepted(View view) {
System.out.println("view: " + view);
}});
channel.connect("ChatCluster");
for (;;) {
String line = Util.readStringFromStdin(": ");
channel.send(null, line);
}
}