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

* java/net/DatagramSocket.java
	(receive): Check with SecurityManager AFTER the packet is received,
	check if connected to multicast address, documentation added.
	(send): Only check SecurityManager if connected, check address of
	packet to send.
	(connect): Implemented, documentation added.
	* java/net/Inet6Address.java: New file (not added yet to Makefile.am).
	* java/net/InetSocketAddress.java
	(whole file): Reindented.
	(hostname): New attribute.
	(InetSocketAddress): Initialize new attribute.
	(getAddress): Documentation added.
	(getHostName): Documentation added.
	(getPort): Documentation added.
	(hashCode): Documentation added.
	(isUnresolved): Documentation added.
	(toString): Conform to output of JDK 1.4.1, documentation added.
	* java/net/MulticastSocket.java
	(joinGroup): Removed FIXME, documentation added.
	(leaveGroup): Removed FIXME, documentation added.
	(send): Documentation added.
	* java/net/Socket.java
	(inputShutdown): New variable.
	(outputShutdown): New variable.
	(Socket): Initialize new variables.
	(getRemoteSocketAddress): Check if connected.
	(shutdownInput): Set new variable.
	(shutdownOutput): Set new variable.
	(isConnected): New method.
	(isClosed): New method.
	(isInputShutdown): New method.
	(isOutputShutdown): New method.
	* java/net/URLStreamHandler.java
	(URLStreamHandler): New method.
	(openConnection): Added documentation.
	(parseURL): Added documentation.
	(getHostAddress): New method.
	(getDefaultPort): New method.

From-SVN: r57772
This commit is contained in:
Michael Koch 2002-10-03 11:23:33 +00:00 committed by Michael Koch
parent 3eacc81d00
commit e832ab3c91
7 changed files with 596 additions and 120 deletions

View file

@ -80,6 +80,9 @@ public class Socket
*/
SocketImpl impl;
private boolean inputShutdown;
private boolean outputShutdown;
SocketChannel ch; // this field must have been set if created by SocketChannel
// Constructors
@ -97,6 +100,9 @@ public class Socket
impl = factory.createSocketImpl();
else
impl = new PlainSocketImpl();
inputShutdown = false;
outputShutdown = false;
}
/**
@ -118,6 +124,8 @@ public class Socket
protected Socket (SocketImpl impl) throws SocketException
{
this.impl = impl;
this.inputShutdown = false;
this.outputShutdown = false;
}
/**
@ -264,6 +272,9 @@ public class Socket
boolean stream) throws IOException
{
this();
this.inputShutdown = false;
this.outputShutdown = false;
if (impl == null)
throw new IOException("Cannot initialize Socket implementation");
@ -457,6 +468,9 @@ public class Socket
*/
public SocketAddress getRemoteSocketAddress()
{
if (!isConnected ())
return null;
return new InetSocketAddress (impl.getInetAddress (), impl.getPort ());
}
@ -886,10 +900,12 @@ public class Socket
*
* @exception IOException If an error occurs.
*/
public void shutdownInput() throws IOException
public void shutdownInput() throws IOException
{
if (impl != null)
impl.shutdownInput();
inputShutdown = true;
}
/**
@ -901,6 +917,8 @@ public class Socket
{
if (impl != null)
impl.shutdownOutput();
outputShutdown = true;
}
/**
@ -993,6 +1011,14 @@ public class Socket
impl.setOption (SocketOptions.IP_TOS, new Integer (tc));
}
/**
* Checks if the socket is connected
*/
public boolean isConnected ()
{
return impl.getInetAddress () != null;
}
/**
* Checks if the socket is already bound.
*/
@ -1000,4 +1026,29 @@ public class Socket
{
return getLocalAddress () != null;
}
/**
* Checks if the socket is closed.
*/
public boolean isClosed ()
{
// FIXME: implement this.
return false;
}
/**
* Checks if the socket's input stream is shutdown
*/
public boolean isInputShutdown ()
{
return inputShutdown;
}
/**
* Checks if the socket's output stream is shutdown
*/
public boolean isOutputShutdown ()
{
return outputShutdown;
}
}