home *** CD-ROM | disk | FTP | other *** search
- package java.net;
-
- import java.io.FileDescriptor;
- import java.io.IOException;
-
- public class ServerSocket {
- private SocketImpl impl;
- private static SocketImplFactory factory;
-
- private ServerSocket() throws IOException {
- this.impl = (SocketImpl)(factory != null ? factory.createSocketImpl() : new PlainSocketImpl());
- }
-
- public ServerSocket(int var1) throws IOException {
- this(var1, 50, (InetAddress)null);
- }
-
- public ServerSocket(int var1, int var2) throws IOException {
- this(var1, var2, (InetAddress)null);
- }
-
- public ServerSocket(int var1, int var2, InetAddress var3) throws IOException {
- this();
- if (var1 >= 0 && var1 <= 65535) {
- try {
- SecurityManager var4 = System.getSecurityManager();
- if (var4 != null) {
- var4.checkListen(var1);
- }
-
- this.impl.create(true);
- if (var3 == null) {
- var3 = InetAddress.anyLocalAddress;
- }
-
- this.impl.bind(var3, var1);
- this.impl.listen(var2);
- } catch (SecurityException var5) {
- this.impl.close();
- throw var5;
- } catch (IOException var6) {
- this.impl.close();
- throw var6;
- }
- } else {
- throw new IllegalArgumentException("Port value out of range: " + var1);
- }
- }
-
- public InetAddress getInetAddress() {
- return this.impl.getInetAddress();
- }
-
- public int getLocalPort() {
- return this.impl.getLocalPort();
- }
-
- public Socket accept() throws IOException {
- Socket var1 = new Socket();
- this.implAccept(var1);
- return var1;
- }
-
- protected final void implAccept(Socket var1) throws IOException {
- try {
- var1.impl.address = new InetAddress();
- var1.impl.fd = new FileDescriptor();
- this.impl.accept(var1.impl);
- SecurityManager var2 = System.getSecurityManager();
- if (var2 != null) {
- var2.checkAccept(var1.getInetAddress().getHostAddress(), var1.getPort());
- }
- } catch (IOException var3) {
- var1.close();
- throw var3;
- } catch (SecurityException var4) {
- var1.close();
- throw var4;
- }
- }
-
- public void close() throws IOException {
- this.impl.close();
- }
-
- public synchronized void setSoTimeout(int var1) throws SocketException {
- this.impl.setOption(4102, new Integer(var1));
- }
-
- public synchronized int getSoTimeout() throws IOException {
- Object var1 = this.impl.getOption(4102);
- return var1 instanceof Integer ? (Integer)var1 : 0;
- }
-
- public String toString() {
- return "ServerSocket[addr=" + this.impl.getInetAddress() + ",port=" + this.impl.getPort() + ",localport=" + this.impl.getLocalPort() + "]";
- }
-
- public static synchronized void setSocketFactory(SocketImplFactory var0) throws IOException {
- if (factory != null) {
- throw new SocketException("factory already defined");
- } else {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkSetFactory();
- }
-
- factory = var0;
- }
- }
- }
-