Created
November 28, 2017 15:32
-
-
Save asissuthar/6eb3e27b0a571d0011f2842e7147a1bf to your computer and use it in GitHub Desktop.
Receive Data Using Broadcast Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package in.asissuthar; | |
import java.io.IOException; | |
import java.net.*; | |
public class Main { | |
public static void main(String[] args) { | |
try { | |
Broadcast broadcast = new Broadcast(8080); | |
broadcast.server(); | |
DatagramPacket packet = broadcast.read(1024); | |
byte[] data = packet.getData(); | |
System.out.println(new String(data)); | |
broadcast.close(); | |
} catch (SocketException socketException) { | |
socketException.printStackTrace(); | |
} catch (IOException ioException) { | |
ioException.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment