dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java
Expertise: Advanced
Apr 5, 2006

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Implementing a Proxy Selector in the Tiger Release of Tiger

Use this code to implement a proxy selector class in the Tiger release of Tiger:

import java.net.*;
import java.util.*;
import java.io.*;

public class MyProxySelector extends ProxySelector{
  
//implement the select method
  public List<java.net.Proxy> select(URI uri)
  {      
  //the proxy servers list  
  List<java.net.Proxy> proxys=new ArrayList<java.net.Proxy>();
  if((uri.getHost()).equals("www.yahoo.com"))
   {
   try{
      InetAddress addr=InetAddress.getLocalHost();
      InetSocketAddress ISA=new InetSocketAddress(addr,808);
      java.net.Proxy proxy=new java.net.Proxy
                                java.net.Proxy.Type.HTTP,ISA);
      proxys.add(proxy);
     }catch(java.net.UnknownHostException e)
            {System.out.println(e.getMessage());}
    }    
    else 
      System.out.println("Unknown address...");
    
    return proxys;    
  }
  
  //the connectFailed method
  public void connectFailed(URI uri, SocketAddress address, IOException ex)
  {
  System.out.println(uri.getHost());
  System.out.println("Fatal error...");
  } 
}
Leonard Anghel
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date