List of usage examples for java.net InetAddress getByName
public static InetAddress getByName(String host) throws UnknownHostException
From source file:ReportByAddress.java
static public void main(String args[]) throws Exception { InetAddress ia = InetAddress.getByName("www.google.ca"); NetworkInterface ni = NetworkInterface.getByInetAddress(ia); System.out.println(ni);/* w w w . java 2 s . co m*/ }
From source file:Main.java
public static void main(String args[]) { try {// w ww. j a v a 2 s . co m InetAddress inetAddr = InetAddress.getByName("www.java2s.com"); System.out.println(inetAddr.toString()); } catch (UnknownHostException ex) { } }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Get hostname by textual representation of IP address InetAddress addr = InetAddress.getByName("127.0.0.1"); }
From source file:Main.java
License:asdf
public static void main(String args[]) throws Exception { InetAddress ia = InetAddress.getByName(args[0]); int port = Integer.parseInt(args[1]); DatagramSocket ds = new DatagramSocket(); while (true) { String s = "asdf"; byte buffer[] = s.getBytes(); DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, port); ds.send(dp);/* w w w . ja v a 2s.com*/ } }
From source file:Main.java
public static void main(String[] argv) throws Exception { int port = 80; Socket socket = new Socket("google.com", port, InetAddress.getByName("java2s.com"), port); }
From source file:GetIP.java
public static void main(String[] args) { InetAddress address = null;//from w w w . jav a 2 s . c o m try { address = InetAddress.getByName("www.java2s.com"); } catch (UnknownHostException e) { System.exit(2); } System.out.println(address.getHostName() + "=" + address.getHostAddress()); System.exit(0); }
From source file:DatagramSender.java
public static void main(String args[]) throws Exception { InetAddress ia = InetAddress.getByName(args[0]); // Obtain destination port int port = Integer.parseInt(args[1]); // Create a datagram socket DatagramSocket ds = new DatagramSocket(); // Create a datagram packet byte buffer[] = args[2].getBytes(); DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, port); ds.send(dp);//from w w w. ja v a2s . c o m }
From source file:Main.java
public static void main(String args[]) { try {/* w w w .j a v a2 s . c om*/ InetAddress ia = InetAddress.getByName("www.java2s.com"); DatagramSocket ds = new DatagramSocket(); byte buffer[] = "hello".getBytes(); DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, 80); ds.setSoTimeout(1000); ds.send(dp); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {// w w w . ja va 2s. co m InetAddress ia = InetAddress.getByName("www.java2s.com"); DatagramSocket ds = new DatagramSocket(); byte buffer[] = "hello".getBytes(); DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, 80); ds.setSendBufferSize(1000); ds.send(dp); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {//from w w w. j a v a 2 s .co m InetAddress ia = InetAddress.getByName("www.java2s.com"); DatagramSocket ds = new DatagramSocket(); byte buffer[] = "hello".getBytes(); DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, 80); ds.setReuseAddress(true); ds.send(dp); } catch (Exception e) { e.printStackTrace(); } }