KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > net > InetSocketAddress

java.net
Class InetSocketAddress

java.lang.Object
  extended by java.net.SocketAddress
      extended by java.net.InetSocketAddress
All Implemented Interfaces:
Serializable
See Also:
Top Examples, Source Code, Socket, ServerSocket

public static InetSocketAddress createUnresolved(String host,
                                                 int port)
See Also:
isUnresolved(), IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final boolean equals(Object obj)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[243]Read data over socket
By Anonymous on 2003/10/26 20:09:31  Rate
import java.io.*; 
 import java.net.*; 
  
  
 public class TimeClient  {  
   public static void main ( String argv [  ]  )  throws Exception  {  
     if ( argv.length != 1 )   {  
      System.out.println ( "Usage: java TimeClient  < timeserver > " ) ; 
      System.exit ( 1 ) ; 
      }  
     InetSocketAddress socketaddress = new InetSocketAddress ( argv [ 0 ] , 13 ) ; 
     Socket time = new Socket (  ) ; 
     time.setSoTimeout ( 2000 ) ; 
     String thetime; 
     StringBuffer sb = new StringBuffer (  ) ; 
     try  {  
       time.connect ( socketaddress,5000 ) ; 
       BufferedReader br = new BufferedReader ( new  
         InputStreamReader ( time.getInputStream (  )  )  ) ; 
       while (  ( thetime = br.readLine (  )  ) != null )   {  
         sb.append ( thetime ) ; 
        }  
       thetime =  ( sb.toString (  )  ) .trim (  ) ; 
       System.out.println ( "Time is: "+thetime ) ; 
      }  catch ( Exception e )   {  
       System.out.println ( "Could not establish connection within 5 seconds." ) ; 
       e.printStackTrace (  ) ; 
       System.exit ( 1 ) ; 
      }  
    }  
  }  
  
  
  
 //equals


public final InetAddress getAddress()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final String getHostName()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final int getPort()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final int hashCode()
See Also:
Hashtable, Object.equals(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public InetSocketAddress(int port)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public InetSocketAddress(String hostname,
                         int port)
See Also:
isUnresolved(), SecurityException, IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public InetSocketAddress(InetAddress addr,
                         int port)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final boolean isUnresolved()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String toString()
See Also:
Object
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags