home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / java / net / MulticastSocket.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  2.6 KB  |  86 lines

  1. package java.net;
  2.  
  3. import java.io.IOException;
  4.  
  5. public class MulticastSocket extends DatagramSocket {
  6.    public MulticastSocket() throws IOException {
  7.    }
  8.  
  9.    public MulticastSocket(int var1) throws IOException {
  10.       super(var1);
  11.    }
  12.  
  13.    void create(int var1, InetAddress var2) throws SocketException {
  14.       SecurityManager var3 = System.getSecurityManager();
  15.       if (var3 != null) {
  16.          var3.checkListen(var1);
  17.       }
  18.  
  19.       try {
  20.          super.impl = (DatagramSocketImpl)DatagramSocket.implClass.newInstance();
  21.       } catch (Exception var5) {
  22.          throw new SocketException("can't instantiate DatagramSocketImpl" + ((Throwable)var5).toString());
  23.       }
  24.  
  25.       super.impl.create();
  26.       super.impl.setOption(4, new Integer(-1));
  27.       super.impl.bind(var1, InetAddress.anyLocalAddress);
  28.    }
  29.  
  30.    public void setTTL(byte var1) throws IOException {
  31.       super.impl.setTTL(var1);
  32.    }
  33.  
  34.    public byte getTTL() throws IOException {
  35.       return super.impl.getTTL();
  36.    }
  37.  
  38.    public void joinGroup(InetAddress var1) throws IOException {
  39.       SecurityManager var2 = System.getSecurityManager();
  40.       if (var2 != null) {
  41.          var2.checkMulticast(var1);
  42.       }
  43.  
  44.       super.impl.join(var1);
  45.    }
  46.  
  47.    public void leaveGroup(InetAddress var1) throws IOException {
  48.       SecurityManager var2 = System.getSecurityManager();
  49.       if (var2 != null) {
  50.          var2.checkMulticast(var1);
  51.       }
  52.  
  53.       super.impl.leave(var1);
  54.    }
  55.  
  56.    public void setInterface(InetAddress var1) throws SocketException {
  57.       super.impl.setOption(16, var1);
  58.    }
  59.  
  60.    public InetAddress getInterface() throws SocketException {
  61.       return (InetAddress)super.impl.getOption(16);
  62.    }
  63.  
  64.    public synchronized void send(DatagramPacket var1, byte var2) throws IOException {
  65.       SecurityManager var3 = System.getSecurityManager();
  66.       if (var3 != null) {
  67.          if (var1.getAddress().isMulticastAddress()) {
  68.             var3.checkMulticast(var1.getAddress(), var2);
  69.          } else {
  70.             var3.checkConnect(var1.getAddress().getHostAddress(), var1.getPort());
  71.          }
  72.       }
  73.  
  74.       byte var4 = this.getTTL();
  75.       if (var2 != var4) {
  76.          super.impl.setTTL(var2);
  77.       }
  78.  
  79.       super.impl.send(var1);
  80.       if (var2 != var4) {
  81.          super.impl.setTTL(var4);
  82.       }
  83.  
  84.    }
  85. }
  86.