PlainSocketImpl.java: Reformated to merge better with classpath's version.

2004-03-11  Michael Koch  <konqueror@gmx.de>

	* gnu/java/net/PlainSocketImpl.java:
	Reformated to merge better with classpath's version.

From-SVN: r79331
This commit is contained in:
Michael Koch 2004-03-11 16:56:30 +00:00 committed by Michael Koch
parent deccda9fff
commit fb36b57afc
2 changed files with 101 additions and 33 deletions

View File

@ -1,3 +1,8 @@
2004-03-11 Michael Koch <konqueror@gmx.de>
* gnu/java/net/PlainSocketImpl.java:
Reformated to merge better with classpath's version.
2004-03-11 Michael Koch <konqueror@gmx.de> 2004-03-11 Michael Koch <konqueror@gmx.de>
* java/util/Locale.java * java/util/Locale.java

View File

@ -200,9 +200,9 @@ public final class PlainSocketImpl extends SocketImpl
*/ */
public native Object getOption(int optID) throws SocketException; public native Object getOption(int optID) throws SocketException;
public native void shutdownInput () throws IOException; public native void shutdownInput() throws IOException;
public native void shutdownOutput () throws IOException; public native void shutdownOutput() throws IOException;
/** /**
* Creates a new socket that is not bound to any local address/port and * Creates a new socket that is not bound to any local address/port and
@ -212,7 +212,7 @@ public final class PlainSocketImpl extends SocketImpl
* *
* @param stream true for a stream socket, false for a datagram socket * @param stream true for a stream socket, false for a datagram socket
*/ */
protected native void create (boolean stream) throws IOException; protected native void create(boolean stream) throws IOException;
/** /**
* Connects to the remote hostname and port specified as arguments. * Connects to the remote hostname and port specified as arguments.
@ -222,9 +222,9 @@ public final class PlainSocketImpl extends SocketImpl
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
protected void connect (String host, int port) throws IOException protected void connect(String host, int port) throws IOException
{ {
connect (new InetSocketAddress (InetAddress.getByName(host), port), 0); connect(InetAddress.getByName(host), port);
} }
/** /**
@ -235,13 +235,19 @@ public final class PlainSocketImpl extends SocketImpl
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
protected void connect (InetAddress host, int port) throws IOException protected void connect(InetAddress host, int port) throws IOException
{ {
connect (new InetSocketAddress (host, port), 0); connect (new InetSocketAddress (host, port), 0);
} }
protected native void connect (SocketAddress addr, int timeout) /**
throws IOException; * Connects to the remote socket address with a specified timeout.
*
* @param timeout The timeout to use for this connect, 0 means infinite.
*
* @exception IOException If an error occurs
*/
protected native void connect(SocketAddress addr, int timeout) throws IOException;
/** /**
* Binds to the specified port on the specified addr. Note that this addr * Binds to the specified port on the specified addr. Note that this addr
@ -252,7 +258,8 @@ public final class PlainSocketImpl extends SocketImpl
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
protected native void bind (InetAddress host, int port) throws IOException; protected native void bind(InetAddress host, int port)
throws IOException;
/** /**
* Starts listening for connections on a socket. The queuelen parameter * Starts listening for connections on a socket. The queuelen parameter
@ -264,9 +271,8 @@ public final class PlainSocketImpl extends SocketImpl
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
protected native void listen (int backlog) throws IOException; protected native void listen(int queuelen)
throws IOException;
private native void accept (PlainSocketImpl s) throws IOException;
/** /**
* Accepts a new connection on this socket and returns in in the * Accepts a new connection on this socket and returns in in the
@ -274,11 +280,15 @@ public final class PlainSocketImpl extends SocketImpl
* *
* @param impl The SocketImpl object to accept this connection. * @param impl The SocketImpl object to accept this connection.
*/ */
protected void accept (SocketImpl s) throws IOException protected void accept(SocketImpl impl)
throws IOException
{ {
accept((PlainSocketImpl) s); accept((PlainSocketImpl) impl);
} }
private native void accept(PlainSocketImpl impl)
throws IOException;
/** /**
* Returns the number of bytes that the caller can read from this socket * Returns the number of bytes that the caller can read from this socket
* without blocking. * without blocking.
@ -298,10 +308,9 @@ public final class PlainSocketImpl extends SocketImpl
* *
* @exception IOException If an error occurs * @exception IOException If an error occurs
*/ */
protected native void close () throws IOException; protected native void close() throws IOException;
protected native void sendUrgentData(int data) protected native void sendUrgentData(int data) throws IOException;
throws IOException;
/** /**
* Returns an InputStream object for reading from this socket. This will * Returns an InputStream object for reading from this socket. This will
@ -336,44 +345,98 @@ public final class PlainSocketImpl extends SocketImpl
} }
/** /**
* A stream which reads from the socket implementation. * This class contains an implementation of <code>InputStream</code> for
* sockets. It in an internal only class used by <code>PlainSocketImpl</code>.
* *
* @author Nic Ferrier <nferrier@tapsellferrier.co.uk> * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
*/ */
final class SocketInputStream final class SocketInputStream
extends InputStream extends InputStream
{ {
public native int read() throws IOException; /**
* Returns the number of bytes available to be read before blocking
*/
public int available() throws IOException
{
return PlainSocketImpl.this.available();
}
public native int read(byte[] buffer, int offset, int length) /**
throws IOException; * This method not only closes the stream, it closes the underlying socket
* (and thus any connection) and invalidates any other Input/Output streams
public final void close() throws IOException * for the underlying impl object
*/
public void close() throws IOException
{ {
PlainSocketImpl.this.close(); PlainSocketImpl.this.close();
} }
public final int available() throws IOException /**
{ * Reads the next byte of data and returns it as an int.
return PlainSocketImpl.this.available(); *
} * @return The byte read (as an int) or -1 if end of stream);
*
* @exception IOException If an error occurs.
*/
public native int read() throws IOException;
/**
* Reads up to len bytes of data into the caller supplied buffer starting
* at offset bytes from the start of the buffer
*
* @param buf The buffer
* @param offset Offset into the buffer to start reading from
* @param len The number of bytes to read
*
* @return The number of bytes actually read or -1 if end of stream
*
* @exception IOException If an error occurs.
*/
public native int read(byte[] buf, int offset, int len) throws IOException;
} }
/** A stream which writes to the socket implementation. /**
* This class is used internally by <code>PlainSocketImpl</code> to be the
* <code>OutputStream</code> subclass returned by its
* <code>getOutputStream method</code>. It expects only to be used in that
* context.
* *
* @author Nic Ferrier <nferrier@tapsellferrier.co.uk> * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
*/ */
final class SocketOutputStream final class SocketOutputStream
extends OutputStream extends OutputStream
{ {
public native void write(int c) throws IOException; /**
* This method closes the stream and the underlying socket connection. This
public native void write(byte[] buffer, int offset, int length) * action also effectively closes any other InputStream or OutputStream
throws IOException; * object associated with the connection.
*
* @exception IOException If an error occurs
*/
public void close() throws IOException public void close() throws IOException
{ {
PlainSocketImpl.this.close(); PlainSocketImpl.this.close();
} }
/**
* Writes a byte (passed in as an int) to the given output stream
*
* @param b The byte to write
*
* @exception IOException If an error occurs
*/
public native void write(int b) throws IOException;
/**
* Writes len number of bytes from the array buf to the stream starting
* at offset bytes into the buffer.
*
* @param buf The buffer
* @param offset Offset into the buffer to start writing from
* @param len The number of bytes to write
*
* @exception IOException If an error occurs.
*/
public native void write(byte[] buf, int offset, int len) throws IOException;
} }
} }