home *** CD-ROM | disk | FTP | other *** search
- package java.net;
-
- import java.io.FileDescriptor;
- import java.io.IOException;
- import netscape.security.PrivilegeManager;
-
- public class ServerSocket {
- protected SocketImpl impl;
- private static SocketImplFactory factory;
-
- protected ServerSocket() throws IOException {
- this.initSocketImpl();
- }
-
- protected void setSocketImpl(SocketImpl var1) {
- if (this.impl == null) {
- this.impl = var1;
- }
-
- }
-
- protected void initSocketImpl() {
- this.setSocketImpl(this.createSocketImpl());
- }
-
- private SocketImpl createSocketImpl() {
- return (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.initSocketImpl();
- 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;
- }
-
- System.getSecurityManager().checkListen(var1);
- 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 {
- PrivilegeManager var2 = PrivilegeManager.getPrivilegeManager();
- if (!var2.hasPrincipal(var1.getClass(), PrivilegeManager.getSystemPrincipal())) {
- PrivilegeManager.checkPrivilegeEnabled("UniversalConnect");
- }
-
- var1.impl.address = new InetAddress();
- var1.impl.fd = new FileDescriptor();
- this.impl.accept(var1.impl);
- SecurityManager var3 = System.getSecurityManager();
- if (var3 != null) {
- var3.checkAccept(var1.getInetAddress().getHostAddress(), var1.getPort());
- }
- } catch (IOException var4) {
- var1.close();
- throw var4;
- } catch (SecurityException var5) {
- var1.close();
- throw var5;
- }
- }
-
- 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;
- }
- }
- }
-