Package java.net

Examples of java.net.InetSocketAddress


  {
    ProtocolDecoder.addSecrets( new byte[][]{ shared_secret });
   
    VirtualServerChannelSelector
      accept_server = VirtualServerChannelSelectorFactory.createNonBlocking(
          new InetSocketAddress( 8765 ),
          0,
          new VirtualServerChannelSelector.SelectListener()
          {
            public void
            newConnectionAccepted(
View Full Code Here


    try{     
      final SocketChannel  channel = SocketChannel.open();
     
      channel.configureBlocking( false );
   
      if ( channel.connect( new InetSocketAddress("localhost", 8765 ))){
             
        outgoing( channel );
       
      }else{
       
View Full Code Here

            ByteBuffer       to_compare,
            int         port )
          {
            total_requests++;
           
            InetSocketAddress  address = transport.getAddress();
           
            int old_limit     = to_compare.limit();
            int old_position   = to_compare.position();

            boolean   ok = false;
View Full Code Here

              Map headers = request.getHeaders();
             
              String user_agent   = (String)headers.get( "user-agent" );
              String client_info   = (String)headers.get( "x-av-client-info" );
             
              InetSocketAddress client_address = request.getClientAddress2();
                         
              boolean  handled = false;
                           
              if ( user_agent != null ){
               
                String lc_agent = user_agent.toLowerCase();
               
                if ( lc_agent.contains( "playstation 3")){
                 
                  handlePS3( client_address );
                 
                  handled = true;
                 
                }else if ( lc_agent.contains( "xbox")){
               
                  handleXBox( client_address );
                 
                  handled = true;
                 
                }else if ( lc_agent.contains( "nintendo wii")){
               
                  handleWii( client_address );
                                   
                  handled = true;

                }else if ( lc_agent.contains( "motorola")) {
                  // Linux/2.6.29 UPnP/1.0 Motorola-DLNA-Stack-DLNADOC/1.50
                  handleGeneric( client_address, "motorola", "Motorola DLNA" );

                  handled = true;

                }else if ( lc_agent.contains( "sec_hhp")) {
                  Matcher match = Pattern.compile("SEC_HHP_(.*)/").matcher(user_agent);
                  if (match.find()) {
                    String name = match.group(1);
                    handleGeneric(client_address, "SEC_HPP_" + name, name);
                    handled = true;
                  }

                }
              }
             
              if ( client_info != null ){
             
                String  lc_info = client_info.toLowerCase();
               
                if ( lc_info.contains( "playstation 3")){
                 
                  handlePS3( client_address );
                 
                  handled = true;
                }
              }
             
              if ( !handled ){
               
                handled = manager.browseReceived( request, browser_args );
              }
             
              if ( !handled ){
               
                String   source = (String)browser_args.get( "source" );
               
                if ( source != null && source.equalsIgnoreCase( "http" )){
                 
                  handleBrowser( client_address );
                                   
                  handled = true;
                }
              }
             
              //if (!handled && user_agent != null && !user_agent.contains("Azureus")) {
              //  handleGeneric(client_address, user_agent == null ? "null": user_agent, user_agent);
              //}
             
              /*
              System.out.println(
                "Received browse: " + request.getClientAddress() +
                ", agent=" + user_agent +
                ", info=" + client_info );
              */
             
              DeviceImpl[] devices = manager.getDevices();
             
              final List<DeviceMediaRendererImpl>  browse_devices = new ArrayList<DeviceMediaRendererImpl>();
             
              boolean  restrict_access = false;
             
              for ( DeviceImpl device: devices ){
             
                if ( device instanceof DeviceMediaRendererImpl ){
               
                  DeviceMediaRendererImpl renderer = (DeviceMediaRendererImpl)device;
                 
                  InetAddress device_address = renderer.getAddress();
                 
                  try{
                    if ( device_address != null ){
                           
                        // just test on IP, should be OK
                     
                      if ( device_address.equals( client_address.getAddress())){
         
                        if ( renderer.canFilterFilesView()){
                       
                          boolean  skip = false;
                         
                          if ( renderer.canRestrictAccess()){
                           
                            String restriction = renderer.getAccessRestriction().trim();
                           
                            if ( restriction.length() > 0 ){
                             
                              String x = client_address.getAddress().getHostAddress();
                             
                              skip = true;
                             
                              String[] ips = restriction.split( "," );
                             
                              for ( String ip: ips ){
                               
                                if ( ip.startsWith( "-" )){
                                 
                                  ip = ip.substring(1);
                                 
                                  if ( ip.equals( x )){
                                   
                                    break;
                                  }
                                }else{
                                 
                                  if ( ip.startsWith( "+" )){
                                   
                                    ip = ip.substring(1);
                                  }
                                 
                                  if ( ip.equals( x )){
                                 
                                    skip = false;
                                   
                                    break;
                                  }
                                }
                              }
                            }
                          }
                         
                          if ( skip ){
                         
                            restrict_access = true;
                           
                            String  host = client_address.getAddress().getHostAddress();
                           
                            synchronized( access_logs){
                             
                              if ( !access_logs.contains( host )){
                               
                                access_logs.add( host );
                             
                                manager.log( "Ignoring browse from " + host + " due to access restriction for '" + renderer.getName() + "'" );
                              }
                            }
                          }
                           
                          browse_devices.add( renderer );
                         
                          renderer.browseReceived();
                        }
                      }
                    }
                  }catch( Throwable e ){
                   
                    Debug.out( e );
                  }
                }
              }
             
              Map<String,Object> result = new HashMap<String, Object>();
             
              if ( browse_devices.size() > 0 ){
               
                synchronized( unassociated_devices ){
                 
                  unassociated_devices.remove( client_address.getAddress() );
                }
               
                final boolean f_restrict_access = restrict_access;
               
                result.put(
                  "filter",
                  new AzureusContentFilter()
                  {
                    public boolean
                    isVisible(
                      AzureusContentDownload  download,
                      Map<String,Object>    browse_args )
                    {
                      if ( f_restrict_access ){
                       
                        return( false );
                      }
                     
                      boolean  visible = false;
                     
                      for ( DeviceUPnPImpl device: browse_devices ){
                       
                        if ( device.isVisible( download )){
                         
                          visible  = true;
                        }
                      }
                     
                      return( visible );
                    }
                   
                    public boolean
                    isVisible(
                      AzureusContentFile    file,
                      Map<String,Object>    browse_args )
                    {
                      if ( f_restrict_access ){
                       
                        return( false );
                      }
                     
                      boolean  visible = false;
                     
                      for ( DeviceUPnPImpl device: browse_devices ){
                       
                        if ( device.isVisible( file )){
                         
                          visible  = true;
                        }
                      }
                     
                      return( visible );
                    }
                  });
              }else{
               
                if ( request.getHeader().substring(0,4).equalsIgnoreCase( "POST" )){
                 
                  synchronized( unassociated_devices ){
                 
                    unassociated_devices.put( client_address.getAddress(), user_agent );
                  }
                }
              }
               
              return( result );
View Full Code Here

      runSupport()
      {
        while( true ){
         
     
          InetSocketAddress  target_address   = null;
          byte[]        data      = null;
         
          msg_queue_sem.reserve();
           
          synchronized( msg_queue ){
View Full Code Here

            ( data[10]& 0xf8 ) != 0 )){
       
        total_packets_received++;
        total_bytes_received += packet.getLength();
       
        listener.receive( handler.getPort(), new InetSocketAddress( packet.getAddress(), packet.getPort()), packet.getData(), packet.getLength());
       
          // consume this packet
       
        return( true );
      }
View Full Code Here

           
          }catch( Throwable e ){
           
          }
       
          InetSocketAddress  target_address   = null;
          InetSocketAddress  source_address   = null;
          byte[]        data      = null;
         
          long  now = SystemTime.getCurrentTime();
         
          synchronized( message_queue ){
View Full Code Here

 
    throws IOException
 
    Long  expires = new Long( SystemTime.getCurrentTime() + latency );
     
    InetSocketAddress local_address = new InetSocketAddress( target.getAddress(), local_port );
     
    synchronized( message_queue ){
       
      if ( random.nextInt(4) != 9 ){
         
View Full Code Here

  }
 
  public InetSocketAddress
  getAddress()
  {
    return( new InetSocketAddress( channel.socket().getInetAddress(), channel.socket().getPort()));
  }
View Full Code Here

  public SocketChannel getSocketChannel(){  return ((TCPTransportHelper)filter.getHelper()).getSocketChannel()}
 
  public InetSocketAddress
  getRemoteAddress()
  {
    return( new InetSocketAddress( getSocketChannel().socket().getInetAddress(), getSocketChannel().socket().getPort()));
  }
View Full Code Here

TOP

Related Classes of java.net.InetSocketAddress

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.