@Override protected void doBind(SocketAddress localAddress) throws Exception { socket.bind(localAddress); }
@Override protected void doBind(SocketAddress localAddress) throws Exception { socket.bind(localAddress); }
@Override protected void doBind(SocketAddress localAddress) throws Exception { socket.bind(localAddress); }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { if (localAddress != null) { socket.bind(localAddress); } boolean success = false; try { socket.connect(remoteAddress); success = true; } finally { if (!success) { try { socket.close(); } catch (Throwable t) { logger.warn("Failed to close a socket.", t); } } } }
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; }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { if (localAddress != null) { socket.bind(localAddress); } boolean success = false; try { socket.connect(remoteAddress); success = true; } finally { if (!success) { try { socket.close(); } catch (Throwable t) { logger.warn("Failed to close a socket.", t); } } } }
@Override protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception { if (localAddress != null) { socket.bind(localAddress); } boolean success = false; try { socket.connect(remoteAddress); success = true; } finally { if (!success) { try { socket.close(); } catch (Throwable t) { logger.warn("Failed to close a socket.", t); } } } }
private void bind( OioDatagramChannel channel, ChannelFuture future, SocketAddress localAddress) { boolean bound = false; boolean workerStarted = false; try { channel.socket.bind(localAddress); bound = true; // Fire events future.setSuccess(); fireChannelBound(channel, channel.getLocalAddress()); // Start the business. DeadLockProofWorker.start( workerExecutor, new ThreadRenamingRunnable( new OioDatagramWorker(channel), "Old I/O datagram worker (" + channel + ')', determiner)); workerStarted = true; } catch (Throwable t) { future.setFailure(t); fireExceptionCaught(channel, t); } finally { if (bound && !workerStarted) { AbstractOioWorker.close(channel, future); } } }
/** * @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; }
public boolean send(String msg, String bindAddr, int bindPort) { MulticastSocket msock = null; try { if ((bindAddr) != null && (0 < bindPort)) { msock = new MulticastSocket(null); msock.bind(new InetSocketAddress(bindAddr, bindPort)); }else{ msock = new MulticastSocket(); } DatagramPacket dgmPacket = new DatagramPacket(msg.getBytes(), msg.length(), ssdpMultiGroup); // Thnaks for Theo Beisch (11/09/04) msock.setTimeToLive(UPnP.getTimeToLive()); msock.send(dgmPacket); } catch (Exception e) { Debug.warning(e); return false; } finally { if (msock != null) msock.close(); } return true; }
@Override protected void doBind(SocketAddress localAddress) throws Exception { socket.bind(localAddress); }
@Override protected void doBind(SocketAddress localAddress) throws Exception { socket.bind(localAddress); }
@Override protected void doBind(SocketAddress localAddress) throws Exception { socket.bind(localAddress); }
@Override public synchronized void bind(SocketAddress addr) throws SocketException { super.bind(addr); this.socketBindings.registerBinding(this); }
public synchronized void bind(SocketAddress addr) throws SocketException { super.bind(addr); this.socketBindings.registerBinding(this); }
private void startMultiCastSocket() throws IOException { skt = new java.net.MulticastSocket( null ); skt.bind( new InetSocketAddress( InetAddress.getByName( "0.0.0.0" ), Discovery.SSDP_PORT ) ); skt.setTimeToLive( Discovery.DEFAULT_TTL ); skt.setSoTimeout( DEFAULT_TIMEOUT ); skt.joinGroup( InetAddress.getByName( Discovery.SSDP_IP ) ); byte[] buf = new byte[2048]; input = new DatagramPacket( buf, buf.length ); }
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; }
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; }