List of usage examples for java.net InetSocketAddress createUnresolved
public static InetSocketAddress createUnresolved(String host, int port)
From source file:Main.java
public static void main(String[] args) { InetSocketAddress addr1 = new InetSocketAddress("::1", 12345); printSocketAddress(addr1);/* w ww.jav a 2 s . co m*/ InetSocketAddress addr2 = InetSocketAddress.createUnresolved("::1", 12881); printSocketAddress(addr2); }
From source file:Main.java
public static void main(String args[]) { try {/* w w w . j a va2 s . c o m*/ InetAddress ia = InetAddress.getByName("www.java2s.com"); DatagramSocket ds = new DatagramSocket(InetSocketAddress.createUnresolved("google.com", 8080)); byte buffer[] = "hello".getBytes(); DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, 80); ds.connect(InetSocketAddress.createUnresolved("google.com", 8080)); ds.send(dp); ds.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {/*from w w w . j a va 2 s. c o 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.bind(InetSocketAddress.createUnresolved("google.com", 8080)); ds.send(dp); ds.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {/*from ww w . j av 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.connect(InetSocketAddress.createUnresolved("google.com", 80)); ds.send(dp); ds.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {//from ww w .j av a2 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.connect(InetSocketAddress.createUnresolved("google.com", 8080)); ds.send(dp); ds.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {/*from w w w . ja va 2 s . c o m*/ InetAddress ia = InetAddress.getByName("www.java2s.com"); DatagramSocket ds = new DatagramSocket(8080, ia); byte buffer[] = "hello".getBytes(); DatagramPacket dp = new DatagramPacket(buffer, buffer.length, ia, 80); ds.connect(InetSocketAddress.createUnresolved("google.com", 8080)); ds.send(dp); ds.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {//from w ww . j av a 2s. c om int port = 80; DatagramSocket ds = new DatagramSocket(port); while (true) { byte buffer[] = new byte[BUFSIZE]; DatagramPacket dp = new DatagramPacket(buffer, buffer.length, InetSocketAddress.createUnresolved("google.com", 8080)); ds.receive(dp); String str = new String(dp.getData()); System.out.println(str); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) { try {/*from w ww.j a va 2 s . c o m*/ int port = 80; DatagramSocket ds = new DatagramSocket(port); byte buffer[] = new byte[BUFSIZE]; while (true) { DatagramPacket dp = new DatagramPacket(buffer, buffer.length); dp.setSocketAddress(InetSocketAddress.createUnresolved("google.com", 8080)); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) throws Exception { int port = 0; byte ttl = (byte) 1; byte[] data = "Here's some multicast data\r\n".getBytes(); DatagramPacket dp = new DatagramPacket(data, data.length, InetAddress.getByName("google.com"), port); MulticastSocket ms = new MulticastSocket(InetSocketAddress.createUnresolved("google.com", 8080)); ms.joinGroup(InetSocketAddress.createUnresolved("127.0.0.1", 8080), NetworkInterface.getByIndex(0)); for (int i = 1; i < 10; i++) { ms.send(dp, ttl);// ww w .j a va 2 s . c o m } ms.leaveGroup(InetAddress.getByName("google.com")); ms.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { int port = 0; byte ttl = (byte) 1; byte[] data = "Here's some multicast data\r\n".getBytes(); DatagramPacket dp = new DatagramPacket(data, data.length, InetAddress.getByName("google.com"), port); MulticastSocket ms = new MulticastSocket(InetSocketAddress.createUnresolved("google.com", 8080)); ms.joinGroup(InetSocketAddress.createUnresolved("127.0.0.1", 8080), NetworkInterface.getByIndex(0)); for (int i = 1; i < 10; i++) { ms.send(dp, ttl);/*from w ww.j a va2s . c om*/ } ms.setLoopbackMode(true); ms.close(); }