Search in sources :

Example 1 with DefaultSocketFactory

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);
}
Also used : DefaultThreadFactory(org.jgroups.util.DefaultThreadFactory) DefaultSocketFactory(org.jgroups.util.DefaultSocketFactory) IpAddress(org.jgroups.stack.IpAddress)

Example 2 with DefaultSocketFactory

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");
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) DefaultSocketFactory(org.jgroups.util.DefaultSocketFactory) IpAddress(org.jgroups.stack.IpAddress) ServerSocket(java.net.ServerSocket) Socket(java.net.Socket)

Example 3 with DefaultSocketFactory

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);
}
Also used : NAKACK2(org.jgroups.protocols.pbcast.NAKACK2) JChannel(org.jgroups.JChannel) DefaultSocketFactory(org.jgroups.util.DefaultSocketFactory) IpAddress(org.jgroups.stack.IpAddress) STABLE(org.jgroups.protocols.pbcast.STABLE) GMS(org.jgroups.protocols.pbcast.GMS)

Aggregations

IpAddress (org.jgroups.stack.IpAddress)3 DefaultSocketFactory (org.jgroups.util.DefaultSocketFactory)3 InetSocketAddress (java.net.InetSocketAddress)1 ServerSocket (java.net.ServerSocket)1 Socket (java.net.Socket)1 JChannel (org.jgroups.JChannel)1 GMS (org.jgroups.protocols.pbcast.GMS)1 NAKACK2 (org.jgroups.protocols.pbcast.NAKACK2)1 STABLE (org.jgroups.protocols.pbcast.STABLE)1 DefaultThreadFactory (org.jgroups.util.DefaultThreadFactory)1