/** * Constructs a multicast socket, bound to the specified {@code port} on the * local host. * * @throws IOException if an error occurs. */ public MulticastSocket(int port) throws IOException { super(port); setReuseAddress(true); }
/** * Constructs a {@code MulticastSocket} bound to the address and port specified by * {@code localAddress}, or an unbound {@code MulticastSocket} if {@code localAddress == null}. * * @throws IllegalArgumentException if {@code localAddress} is not supported (because it's not * an {@code InetSocketAddress}, say). * @throws IOException if an error occurs. */ public MulticastSocket(SocketAddress localAddress) throws IOException { super(localAddress); setReuseAddress(true); }
/** * Constructs a multicast socket, bound to any available port on the * local host. * * @throws IOException if an error occurs. */ public MulticastSocket() throws IOException { setReuseAddress(true); }
protected MulticastSocket createMulticastSocket(String service_name, int port) throws Exception { // Creates an *unbound* multicast socket (because SocketAddress is null) MulticastSocket retval=getSocketFactory().createMulticastSocket(service_name, null); // causes *no* binding ! if(bind_addr != null) setInterface(bind_addr, retval); retval.setReuseAddress(false); // so we get a conflict if binding to the same port and increment the port retval.bind(new InetSocketAddress(bind_addr, port)); return retval; }
synchronized public void init(NetworkInterface networkInterface, Router router, NetworkAddressFactory networkAddressFactory, DatagramProcessor datagramProcessor) throws InitializationException { this.router = router; this.networkAddressFactory = networkAddressFactory; this.datagramProcessor = datagramProcessor; this.multicastInterface = networkInterface; try { log.info("Creating wildcard socket (for receiving multicast datagrams) on port: " + configuration.getPort()); multicastAddress = new InetSocketAddress(configuration.getGroup(), configuration.getPort()); socket = new MulticastSocket(configuration.getPort()); socket.setReuseAddress(true); socket.setReceiveBufferSize(32768); // Keep a backlog of incoming datagrams if we are not fast enough log.info("Joining multicast group: " + multicastAddress + " on network interface: " + multicastInterface.getDisplayName()); socket.joinGroup(multicastAddress, multicastInterface); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex); } }
socket.setInterface(localHost); socket.setSoTimeout(Integer.getInteger("AvailablePort.timeout", 2000).intValue()); socket.setReuseAddress(true); byte[] buffer = new byte[4]; buffer[0] = (byte) 'p';
socket.setReuseAddress(config.getReuseAddress());
/** * @param addr {@link String} rappresenting the multicast hostname to join into. * @param port int rappresenting the port to be use poth as source and destination * @param bindAddr {@link InetAddress} which identify the hostname of the interface * to use for sending and recieving multicast packet */ public boolean open(String addr,int port, InetAddress bindAddr){ try { ssdpMultiSock = new MulticastSocket(null); ssdpMultiSock.setReuseAddress(true); InetSocketAddress bindSockAddr = new InetSocketAddress(port); ssdpMultiSock.bind(bindSockAddr); ssdpMultiGroup = new InetSocketAddress(InetAddress.getByName(addr), port); ssdpMultiIf = NetworkInterface.getByInetAddress(bindAddr); ssdpMultiSock.joinGroup(ssdpMultiGroup, ssdpMultiIf); } catch (Exception e) { Debug.warning(e); return false; } return true; }
static MulticastSocket newMulticastSocket(InetAddress pAddress, LogHandler pLogHandler) throws IOException { // TODO: IpV6 (not supported yet) InetSocketAddress socketAddress = new InetSocketAddress(JOLOKIA_MULTICAST_GROUP, JOLOKIA_MULTICAST_PORT); MulticastSocket socket = new MulticastSocket(JOLOKIA_MULTICAST_PORT); socket.setReuseAddress(true); setOutgoingInterfaceForMulticastRequest(pAddress, socket); socket.setTimeToLive(255); if (joinMcGroupsOnAllNetworkInterfaces(socket, socketAddress, pLogHandler) == 0) { throw new IOException("Couldn't join multicast group " + socketAddress + " on any network interfaces"); } return socket; }
synchronized public void init(NetworkInterface networkInterface, Router router, NetworkAddressFactory networkAddressFactory, DatagramProcessor datagramProcessor) throws InitializationException { this.router = router; this.networkAddressFactory = networkAddressFactory; this.datagramProcessor = datagramProcessor; this.multicastInterface = networkInterface; try { log.info("Creating wildcard socket (for receiving multicast datagrams) on port: " + configuration.getPort()); multicastAddress = new InetSocketAddress(configuration.getGroup(), configuration.getPort()); socket = new MulticastSocket(configuration.getPort()); socket.setReuseAddress(true); socket.setReceiveBufferSize(32768); // Keep a backlog of incoming datagrams if we are not fast enough log.info("Joining multicast group: " + multicastAddress + " on network interface: " + multicastInterface.getDisplayName()); socket.joinGroup(multicastAddress, multicastInterface); } catch (Exception ex) { throw new InitializationException("Could not initialize " + getClass().getSimpleName() + ": " + ex); } }
/** * Constructs a multicast socket, bound to any available port on the * local host. * * @throws IOException if an error occurs. */ public MulticastSocket() throws IOException { setReuseAddress(true); }
/** * Constructs a multicast socket, bound to the specified {@code port} on the * local host. * * @throws IOException if an error occurs. */ public MulticastSocket(int port) throws IOException { super(port); setReuseAddress(true); }
/** * Constructs a {@code MulticastSocket} bound to the address and port specified by * {@code localAddress}, or an unbound {@code MulticastSocket} if {@code localAddress == null}. * * @throws IllegalArgumentException if {@code localAddress} is not supported (because it's not * an {@code InetSocketAddress}, say). * @throws IOException if an error occurs. */ public MulticastSocket(SocketAddress localAddress) throws IOException { super(localAddress); setReuseAddress(true); }
/** * Constructs a multicast socket, bound to the specified {@code port} on the * local host. * * @throws IOException if an error occurs. */ public MulticastSocket(int port) throws IOException { super(port); setReuseAddress(true); }
/** * Constructs a {@code MulticastSocket} bound to the address and port specified by * {@code localAddress}, or an unbound {@code MulticastSocket} if {@code localAddress == null}. * * @throws IllegalArgumentException if {@code localAddress} is not supported (because it's not * an {@code InetSocketAddress}, say). * @throws IOException if an error occurs. */ public MulticastSocket(SocketAddress localAddress) throws IOException { super(localAddress); setReuseAddress(true); }
/** * Constructs a multicast socket, bound to any available port on the * local host. * * @throws IOException if an error occurs. */ public MulticastSocket() throws IOException { setReuseAddress(true); }
/** * Constructs a multicast socket, bound to any available port on the * local host. * * @throws IOException if an error occurs. */ public MulticastSocket() throws IOException { setReuseAddress(true); }
synchronized private void createSocket(InetAddress address) throws IOException { if (multicastSocket != null) { multicastSocket.close(); } // create socket multicastSocket = new MulticastSocket(PORT); multicastSocket.setReuseAddress(true); multicastSocket.setSoTimeout(130000); multicastSocket.joinGroup(address); sendDiscoveryPacket(); multicastSocket.setSoTimeout(2000); }
protected MulticastSocket createMulticastSocket(String service_name, int port) throws Exception { // Creates an *unbound* multicast socket (because SocketAddress is null) MulticastSocket retval=getSocketFactory().createMulticastSocket(service_name, null); // causes *no* binding ! if(bind_addr != null) setInterface(bind_addr, retval); retval.setReuseAddress(false); // so we get a conflict if binding to the same port and increment the port retval.bind(new InetSocketAddress(bind_addr, port)); return retval; }
protected MulticastSocket createMulticastSocket(String service_name, int port) throws Exception { // Creates an *unbound* multicast socket (because SocketAddress is null) MulticastSocket retval=getSocketFactory().createMulticastSocket(service_name, null); // causes *no* binding ! if(bind_addr != null) setInterface(bind_addr, retval); retval.setReuseAddress(false); // so we get a conflict if binding to the same port and increment the port retval.bind(new InetSocketAddress(bind_addr, port)); return retval; }