2002-09-25 Michael Koch <konqueror@gmx.de>

* java/net/DatagramSocket.java
	(DatagramSocket): Exception documentation added.
	(bind): Exception documentation added, addded SecurityManager check,
	added SocketAddress type check.
	(getSoTimeout): Check impl.
	(receive): Fix SecurityManager check, check impl, documentation added.
	(send): Check channel mode, documentation added.
	(connect): New method.
	(disconnect): Implemented.
	(getLocalSocketAddress): New method.
	(getReceiveBufferSize): Check impl.
	(setReuseAddress): Check impl.
	(getReuseAddress): Check impl.
	(setBroadcast): Check impl.
	(getBroadcast): Check impl.
	(setTrafficClass): Check impl, Documentation cleared.
	(getTrafficClass): Check impl.
	(getSendBufferSize): Check impl.
	(setReceiveBufferSize): Check impl, documentation added.
	(setSendBufferSize): Documentation added.
	(setDatagramSocketImplFactory): New method.
	* java/net/HttpURLConnection.java
	(HTTP_INTERNAL_ERROR): The correct code is 500.
	(HTTP_NOT_IMPLEMENTED): Added new constant.
	(setFollowRedirects): Documentation added.
	(getInstanceFollowRedirects): New method.
	(setInstanceFollowRedirects): New method.
	(setRequestMethod): Documentation added.
	(getResponseCode): Documentation added.
	(getResponseMessage): Documentation added.
	* java/net/JarURLConnection.java
	(JarURLConnection): protected since JDK 1.4.
	(getJarEntry): java.io.IOException to IOException, documentation added.
	(getJarFile): Documentation added.
	* java/net/ServerSocket.java
	(ServerSocket): Private to public, exception added.
	(ServerSocket): java.io.IOException to IOException, documentation added.
	(bind): Check socket address type, documentation added.
	(bind): java.io.IOException to IOException, documentation added.
	(accept): Documentation added.
	(implAccept): Check ch is not non-blocking, documentation added.
	(setSoTimeout): Documentation fixed.
	(setReceiveBufferSize): Documentation added.
	* java/net/Socket.java
	(Socket): Documentation added.
	(bind): Documentation added.
	(connect): Check socket address type, documentation added.
	(getRemoteSocketAddress): New method.

From-SVN: r57494
This commit is contained in:
Michael Koch 2002-09-25 09:05:53 +00:00 committed by Michael Koch
parent 33c31b33b5
commit df79dc1a89
10 changed files with 601 additions and 28 deletions

View file

@ -38,6 +38,7 @@ exception statement from your version. */
package java.net;
import java.io.IOException;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.ServerSocketChannel;
/* Written using on-line Java Platform 1.2 API Specification.
@ -50,7 +51,7 @@ import java.nio.channels.ServerSocketChannel;
* listens for and accepts connections. At that point the client and
* server sockets are ready to communicate with one another utilizing
* whatever application layer protocol they desire.
* <p>
*
* As with the <code>Socket</code> class, most instance methods of this class
* simply redirect their calls to an implementation class.
*
@ -82,9 +83,13 @@ public class ServerSocket
private ServerSocketChannel ch;
/**
* Private constructor that simply sets the implementation.
* Constructor that simply sets the implementation.
*
* @exception IOException If an error occurs
*
* @specnote This constructor is public since JDK 1.4
*/
private ServerSocket()
public ServerSocket() throws IOException
{
if (factory != null)
impl = factory.createSocketImpl();
@ -100,9 +105,11 @@ public class ServerSocket
* @param port The port number to bind to
*
* @exception IOException If an error occurs
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
*/
public ServerSocket (int port)
throws java.io.IOException
throws IOException
{
this(port, 50);
}
@ -117,9 +124,11 @@ public class ServerSocket
* @param backlog The length of the pending connection queue
*
* @exception IOException If an error occurs
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
*/
public ServerSocket (int port, int backlog)
throws java.io.IOException
throws IOException
{
this(port, backlog, null);
}
@ -136,11 +145,13 @@ public class ServerSocket
* @param bindAddr The address to bind to, or null to bind to all addresses
*
* @exception IOException If an error occurs
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
*
* @since 1.1
*/
public ServerSocket (int port, int backlog, InetAddress bindAddr)
throws java.io.IOException
throws IOException
{
this();
if (impl == null)
@ -164,6 +175,9 @@ public class ServerSocket
* @param endpoint The socket address to bind to
*
* @exception IOException If an error occurs
* @exception IllegalArgumentException If address type is not supported
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
*
* @since 1.4
*/
@ -173,6 +187,9 @@ public class ServerSocket
if (impl == null)
throw new IOException ("Cannot initialize Socket implementation");
if (! (endpoint instanceof InetSocketAddress))
throw new IllegalArgumentException ("Address type not supported");
InetSocketAddress tmp = (InetSocketAddress) endpoint;
SecurityManager s = System.getSecurityManager ();
@ -187,14 +204,22 @@ public class ServerSocket
*
* @param endpoint The socket address to bind to
* @param backlog The length of the pending connection queue
*
* @exception IOException If an error occurs
* @exception IllegalArgumentException If address type is not supported
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
*
* @since 1.4
*/
public void bind (SocketAddress endpoint, int backlog)
throws java.io.IOException
public void bind (SocketAddress endpoint, int backlog) throws IOException
{
if (impl == null)
throw new IOException ("Cannot initialize Socket implementation");
if (! (endpoint instanceof InetSocketAddress))
throw new IllegalArgumentException ("Address type not supported");
InetSocketAddress tmp = (InetSocketAddress) endpoint;
SecurityManager s = System.getSecurityManager ();
@ -253,8 +278,14 @@ public class ServerSocket
* connection is available.
*
* @exception IOException If an error occurs
* @exception SecurityException If a security manager exists and its
* checkListen method doesn't allow the operation
* @exception IllegalBlockingModeException If this socket has an associated
* channel, and the channel is in non-blocking mode
* @exception SocketTimeoutException If a timeout was previously set with
* setSoTimeout and the timeout has been reached
*/
public Socket accept () throws IOException
public Socket accept () throws IOException
{
Socket s = new Socket();
implAccept (s);
@ -270,11 +301,17 @@ public class ServerSocket
* @param socket The socket that is used for the accepted connection
*
* @exception IOException If an error occurs
* @exception IllegalBlockingModeException If this socket has an associated
* channel, and the channel is in non-blocking mode
*
* @since 1.1
*/
protected final void implAccept (Socket s) throws IOException
protected final void implAccept (Socket s)
throws IOException
{
if (ch != null && !ch.isBlocking())
throw new IllegalBlockingModeException();
impl.accept(s.impl);
}
@ -329,7 +366,7 @@ public class ServerSocket
*
* @param timeout The new SO_TIMEOUT value
*
* @exception IOException If an error occurs
* @exception SocketException If an error occurs
*
* @since 1.1
*/
@ -408,6 +445,7 @@ public class ServerSocket
* @param size The new receive buffer size.
*
* @exception SocketException If an error occurs or Socket is not connected
* @exception IllegalArgumentException If size is 0 or negative
*
* @since 1.4
*/