diff options
author | Tom Tromey <tromey@gcc.gnu.org> | 1999-04-07 14:42:40 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 1999-04-07 14:42:40 +0000 |
commit | ee9dd3721be68b9fa63dea9aa5a1d86e66958cde (patch) | |
tree | d96801a16fdf03a5682ef98730fe333a46eef944 /libjava/java/net/ServerSocket.java | |
parent | 140fa895c6b859f827fc4437b91775a82cd105fb (diff) | |
download | gcc-ee9dd3721be68b9fa63dea9aa5a1d86e66958cde.zip gcc-ee9dd3721be68b9fa63dea9aa5a1d86e66958cde.tar.gz gcc-ee9dd3721be68b9fa63dea9aa5a1d86e66958cde.tar.bz2 |
Initial revision
From-SVN: r26263
Diffstat (limited to 'libjava/java/net/ServerSocket.java')
-rw-r--r-- | libjava/java/net/ServerSocket.java | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java new file mode 100644 index 0000000..e4b5069 --- /dev/null +++ b/libjava/java/net/ServerSocket.java @@ -0,0 +1,105 @@ +// Socket.java + +/* Copyright (C) 1999 Cygnus Solutions + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +/** + * @author Per Bothner <bothner@cygnus.com> + * @date January 6, 1999. + */ + +/** Written using on-line Java Platform 1.2 API Specification. + * Status: I believe all methods are implemented, but many + * of them just throw an exception. + */ + +package java.net; +import java.io.*; + +public class ServerSocket +{ + static SocketImplFactory factory; + SocketImpl impl; + + public ServerSocket (int port) + throws java.io.IOException + { + this(port, 5); + } + + public ServerSocket (int port, int backlog) + throws java.io.IOException + { + this(port, backlog, InetAddress.getLocalHost()); + } + + public ServerSocket (int port, int backlog, InetAddress bindAddr) + throws java.io.IOException + { + if (factory == null) + this.impl = new PlainSocketImpl(); + else + this.impl = factory.createSocketImpl(); + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkListen(port); + impl.create(true); + impl.bind(bindAddr, port); + impl.listen(backlog); + } + + public InetAddress getInetAddress() + { + return impl.getInetAddress(); + } + + public int getLocalPort() + { + return impl.getLocalPort(); + } + + public Socket accept () throws IOException + { + Socket s = new Socket(Socket.factory == null ? new PlainSocketImpl() + : Socket.factory.createSocketImpl()); + implAccept (s); + return s; + } + + protected final void implAccept (Socket s) throws IOException + { + impl.accept(s.impl); + } + + public void close () throws IOException + { + impl.close(); + } + + public void setSoTimeout (int timeout) throws SocketException + { + throw new InternalError("ServerSocket.setSoTimeout not implemented"); + } + + public int getSoTimeout () throws SocketException + { + throw new InternalError("ServerSocket.getSoTimeout not implemented"); + } + + public String toString () + { + return impl.toString(); + } + + public static void setSocketImplFactory (SocketImplFactory fac) + throws IOException + { + factory = fac; + } + +} |