Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. /** Constructor */
  2.     private MulticastChannel() {
  3.  
  4.         /** configuration via properties file, terminate if not found! */
  5.         String address = constants.get(ZephyrOpen.address);
  6.         String port = constants.get(ZephyrOpen.port);
  7.  
  8.         if (address == null) {
  9.             constants.error("serverAddress not found in properties file, terminate!", this);
  10.             constants.shutdown();
  11.         }
  12.  
  13.         if (port == null) {
  14.             constants.error("serverPort not found in properties file, terminate!", this);
  15.             constants.shutdown();
  16.         }
  17.  
  18.         try {
  19.  
  20.             groupPort = Integer.parseInt(port);
  21.  
  22.             /** get group ip */
  23.             groupAddress = InetAddress.getByName(address);
  24.  
  25.             /** construct the server socket */
  26.             serverSocket = new MulticastSocket(groupPort);
  27.  
  28.             /** join this group */
  29.             serverSocket.joinGroup(groupAddress);
  30.  
  31.             /** find our ip */
  32.             local = constants.get(ZephyrOpen.localAddress);
  33.  
  34.         } catch (Exception e) {
  35.             constants.shutdown(e);
  36.         }
  37.  
  38.         /** start thread, block wait on input from socket */
  39.         server = new Thread(this);
  40.         server.setDaemon(true);
  41.         server.start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement