home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / net / ServerSocket.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.9 KB  |  118 lines

  1. package java.net;
  2.  
  3. import java.io.FileDescriptor;
  4. import java.io.IOException;
  5.  
  6. public class ServerSocket {
  7.    private SocketImpl impl;
  8.    private static SocketImplFactory factory;
  9.  
  10.    private ServerSocket() throws IOException {
  11.       this.impl = (SocketImpl)(factory != null ? factory.createSocketImpl() : new PlainSocketImpl());
  12.    }
  13.  
  14.    public ServerSocket(int var1) throws IOException {
  15.       this(var1, 50, (InetAddress)null);
  16.    }
  17.  
  18.    public ServerSocket(int var1, int var2) throws IOException {
  19.       this(var1, var2, (InetAddress)null);
  20.    }
  21.  
  22.    public ServerSocket(int var1, int var2, InetAddress var3) throws IOException {
  23.       this();
  24.       if (var1 >= 0 && var1 <= 65535) {
  25.          try {
  26.             SecurityManager var4 = System.getSecurityManager();
  27.             if (var4 != null) {
  28.                var4.checkListen(var1);
  29.             }
  30.  
  31.             this.impl.create(true);
  32.             if (var3 == null) {
  33.                var3 = InetAddress.anyLocalAddress;
  34.             }
  35.  
  36.             this.impl.bind(var3, var1);
  37.             this.impl.listen(var2);
  38.          } catch (SecurityException var6) {
  39.             this.impl.close();
  40.             throw var6;
  41.          } catch (IOException var7) {
  42.             this.impl.close();
  43.             throw var7;
  44.          }
  45.       } else {
  46.          throw new IllegalArgumentException("Port value out of range: " + var1);
  47.       }
  48.    }
  49.  
  50.    public InetAddress getInetAddress() {
  51.       return this.impl.getInetAddress();
  52.    }
  53.  
  54.    public int getLocalPort() {
  55.       return this.impl.getLocalPort();
  56.    }
  57.  
  58.    public Socket accept() throws IOException {
  59.       Socket var1 = new Socket();
  60.       this.implAccept(var1);
  61.       return var1;
  62.    }
  63.  
  64.    protected final void implAccept(Socket var1) throws IOException {
  65.       SocketImpl var2 = var1.impl;
  66.  
  67.       try {
  68.          var1.impl = null;
  69.          var2.address = new InetAddress();
  70.          var2.fd = new FileDescriptor();
  71.          this.impl.accept(var2);
  72.          SecurityManager var3 = System.getSecurityManager();
  73.          if (var3 != null) {
  74.             var3.checkAccept(var2.getInetAddress().getHostAddress(), var2.getPort());
  75.          }
  76.       } catch (IOException var10) {
  77.          var2.reset();
  78.          throw var10;
  79.       } catch (SecurityException var11) {
  80.          var2.reset();
  81.          throw var11;
  82.       } finally {
  83.          var1.impl = var2;
  84.       }
  85.  
  86.    }
  87.  
  88.    public void close() throws IOException {
  89.       this.impl.close();
  90.    }
  91.  
  92.    public synchronized void setSoTimeout(int var1) throws SocketException {
  93.       this.impl.setOption(4102, new Integer(var1));
  94.    }
  95.  
  96.    public synchronized int getSoTimeout() throws IOException {
  97.       Object var1 = this.impl.getOption(4102);
  98.       return var1 instanceof Integer ? (Integer)var1 : 0;
  99.    }
  100.  
  101.    public String toString() {
  102.       return "ServerSocket[addr=" + this.impl.getInetAddress() + ",port=" + this.impl.getPort() + ",localport=" + this.impl.getLocalPort() + "]";
  103.    }
  104.  
  105.    public static synchronized void setSocketFactory(SocketImplFactory var0) throws IOException {
  106.       if (factory != null) {
  107.          throw new SocketException("factory already defined");
  108.       } else {
  109.          SecurityManager var1 = System.getSecurityManager();
  110.          if (var1 != null) {
  111.             var1.checkSetFactory();
  112.          }
  113.  
  114.          factory = var0;
  115.       }
  116.    }
  117. }
  118.