use of org.jgroups.util.DefaultSocketFactory in project JGroups by belaban.
the class PubServer method start.
protected void start(InetAddress bind_addr, int port, boolean nio, int recv_buf_size) throws Exception {
server = nio ? new NioServer(new DefaultThreadFactory("pubsrv", false), new DefaultSocketFactory(), bind_addr, port, port + 50, null, 0, recv_buf_size) : new TcpServer(new DefaultThreadFactory("pubsrv", false), new DefaultSocketFactory(), bind_addr, port, port + 50, null, 0, recv_buf_size);
server.receiver(this);
server.start();
JmxConfigurator.register(server, Util.getMBeanServer(), "pub:name=pub-server");
int local_port = server.localAddress() instanceof IpAddress ? ((IpAddress) server.localAddress()).getPort() : 0;
System.out.printf("\nPubServer listening at %s:%s\n", bind_addr != null ? bind_addr : "0.0.0.0", local_port);
}
use of org.jgroups.util.DefaultSocketFactory in project JGroups by belaban.
the class UnicastTestTcp method init.
public void init(String local_addr, String remote_addr, int local_port, int remote_port) throws Exception {
local = new InetSocketAddress(local_addr, local_port);
remote = new InetSocketAddress(remote_addr, remote_port);
destination = new IpAddress(remote.getAddress(), remote.getPort());
srv_sock = Util.createServerSocket(new DefaultSocketFactory(), "server", local.getAddress(), local.getPort(), local.getPort(), 0);
System.out.println("Listening on " + srv_sock.getLocalSocketAddress());
acceptor = new Acceptor();
acceptor.start();
sock = new Socket();
// sock.bind(local);
sock.setSendBufferSize(SOCK_SEND_BUF_SIZE);
sock.setReceiveBufferSize(SOCK_RECV_BUF_SIZE);
try {
sock.connect(remote);
output = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
System.out.println("Connected to " + sock.getRemoteSocketAddress());
} catch (Throwable t) {
System.out.println("Failed connecting to " + remote + ": will only act as server");
}
}
use of org.jgroups.util.DefaultSocketFactory in project JGroups by belaban.
the class TLSTest method create.
private JChannel create(String name) throws Exception {
TCP transport = new TCP();
transport.setBindAddress(InetAddress.getLoopbackAddress());
transport.setBindPort(9600);
transport.setSocketFactory(sslContexts.containsKey(name) ? new DefaultSocketFactory(sslContexts.get(name)) : new DefaultSocketFactory());
TCPPING ping = new TCPPING();
ping.setInitialHosts2(Collections.singletonList(new IpAddress(transport.getBindAddress(), transport.getBindPort())));
return new JChannel(transport, ping, new NAKACK2(), new UNICAST3(), new STABLE(), new GMS()).name(name);
}
Aggregations