return factory.createDatagramSocket(service_name); return factory.createDatagramSocket(service_name,port); while(port < MAX_PORT) { try { return factory.createDatagramSocket(service_name,port,addr);
public void init() throws Exception { super.init(); if (timer == null) throw new Exception("timer cannot be retrieved from protocol stack"); if(gossip_router_hosts.isEmpty()) throw new IllegalStateException("gossip_router_hosts needs to contain at least one address of a GossipRouter"); log.debug("GossipRouters are:" + gossip_router_hosts.toString()); stubManager = RouterStubManager.emptyGossipClientStubManager(this).useNio(this.use_nio); sock = getSocketFactory().createDatagramSocket("jgroups.tunnel.ucast_sock", bind_port, bind_addr); }
public void start() throws Exception { for(int i=bind_port; i <= bind_port+port_range; i++) { try { sock=getSocketFactory().createDatagramSocket("jgroups.bping.sock", i); break; } catch(Throwable t) { if(i > bind_port+port_range) throw new RuntimeException("failed to open a port in range [" + bind_port + " - " + (bind_port+port_range) + "]", t); } } if (null == sock) throw new RuntimeException("failed to open a port in range [" + bind_port + " - " + (bind_port+port_range) + "]"); sock.setBroadcast(true); startReceiver(); super.start(); }
private void createDatagramSocket(String serviceName, String bindingName) throws IOException { DatagramSocket socket1 = mock(DatagramSocket.class); DatagramSocket socket2 = mock(DatagramSocket.class); DatagramSocket socket3 = mock(DatagramSocket.class); DatagramSocket socket4 = mock(DatagramSocket.class); InetAddress localhost = InetAddress.getLocalHost(); SocketAddress socketAddress = new InetSocketAddress(localhost, 2); when(this.manager.createDatagramSocket(bindingName)).thenReturn(socket1); when(this.manager.createDatagramSocket(bindingName, new InetSocketAddress(1))).thenReturn(socket2); when(this.manager.createDatagramSocket(bindingName, socketAddress)).thenReturn(socket3); when(this.manager.createDatagramSocket(bindingName, new InetSocketAddress(localhost, 1))).thenReturn(socket4); DatagramSocket result1 = this.subject.createDatagramSocket(serviceName); DatagramSocket result2 = this.subject.createDatagramSocket(serviceName, 1); DatagramSocket result3 = this.subject.createDatagramSocket(serviceName, socketAddress); DatagramSocket result4 = this.subject.createDatagramSocket(serviceName, 1, localhost); assertSame(socket1, result1); assertSame(socket2, result2); assertSame(socket3, result3); assertSame(socket4, result4); }
return factory.createDatagramSocket(service_name); return factory.createDatagramSocket(service_name,port); while(port < MAX_PORT) { try { return factory.createDatagramSocket(service_name,port,addr);
@Override public DatagramSocket createDatagramSocket(String name) throws SocketException { return this.register(this.factory.createDatagramSocket(name)); }
@Override public DatagramSocket createDatagramSocket(String name, SocketAddress bindAddress) throws SocketException { return this.register(this.factory.createDatagramSocket(name, bindAddress)); }
@Override public DatagramSocket createDatagramSocket(String name) throws SocketException { return this.register(this.factory.createDatagramSocket(name)); }
@Override public DatagramSocket createDatagramSocket(String name, int port, InetAddress localAddress) throws SocketException { return this.register(this.factory.createDatagramSocket(name, port, localAddress)); }
@Override public DatagramSocket createDatagramSocket(String name, int port) throws SocketException { return this.register(this.factory.createDatagramSocket(name, port)); }
@Override public DatagramSocket createDatagramSocket(String name, int port, InetAddress localAddress) throws SocketException { return this.register(this.factory.createDatagramSocket(name, port, localAddress)); }
@Override public DatagramSocket createDatagramSocket(String name, SocketAddress bindAddress) throws SocketException { return this.register(this.factory.createDatagramSocket(name, bindAddress)); }
@Override public DatagramSocket createDatagramSocket(String name, int port) throws SocketException { return this.register(this.factory.createDatagramSocket(name, port)); }
public void init() throws Exception { super.init(); if (timer == null) throw new Exception("timer cannot be retrieved from protocol stack"); if(gossip_router_hosts.isEmpty()) throw new IllegalStateException("gossip_router_hosts needs to contain at least one address of a GossipRouter"); log.debug("GossipRouters are:" + gossip_router_hosts.toString()); stubManager = RouterStubManager.emptyGossipClientStubManager(this).useNio(this.use_nio); sock = getSocketFactory().createDatagramSocket("jgroups.tunnel.ucast_sock", bind_port, bind_addr); }
public void start() throws Exception { for(int i=bind_port; i <= bind_port+port_range; i++) { try { sock=getSocketFactory().createDatagramSocket("jgroups.bping.sock", i); break; } catch(Throwable t) { if(i > bind_port+port_range) throw new RuntimeException("failed to open a port in range [" + bind_port + " - " + (bind_port+port_range) + "]", t); } } if (null == sock) throw new RuntimeException("failed to open a port in range [" + bind_port + " - " + (bind_port+port_range) + "]"); sock.setBroadcast(true); startReceiver(); super.start(); }
@Test public void createDatagram() throws IOException { DatagramSocket socket1 = new DatagramSocket(); DatagramSocket socket2 = new DatagramSocket(); DatagramSocket socket3 = new DatagramSocket(); DatagramSocket socket4 = new DatagramSocket(); InetAddress localhost = InetAddress.getLocalHost(); SocketAddress socketAddress = new InetSocketAddress(localhost, 1); when(this.factory.createDatagramSocket("test")).thenReturn(socket1); when(this.factory.createDatagramSocket("test", 1)).thenReturn(socket2); when(this.factory.createDatagramSocket("test", socketAddress)).thenReturn(socket3); when(this.factory.createDatagramSocket("test", 1, localhost)).thenReturn(socket4); DatagramSocket result1 = this.subject.createDatagramSocket("test"); DatagramSocket result2 = this.subject.createDatagramSocket("test", 1); DatagramSocket result3 = this.subject.createDatagramSocket("test", socketAddress); DatagramSocket result4 = this.subject.createDatagramSocket("test", 1, localhost); verify(this.manager.getUnnamedRegistry()).registerSocket(socket1); verify(this.manager.getUnnamedRegistry()).registerSocket(socket2); verify(this.manager.getUnnamedRegistry()).registerSocket(socket3); verify(this.manager.getUnnamedRegistry()).registerSocket(socket4); assertSame(socket1, result1); assertSame(socket2, result2); assertSame(socket3, result3); assertSame(socket4, result4); }