[kaffe] public Socket(String host, int port, InetAddress localAddr, int localPort)

Oskar Sandberg oskar at freenetproject.org
Wed Nov 6 16:05:43 PST 2002


The constructor

public Socket(String host, int port, InetAddress localAddr, int localPort)

for java.net.Socket throws an UnimplemetedException even though as far 
as I can tell all the necessary code in PlainSocketImpl is implemented. 
Does anybody know if there is a reason for this?

FWIW I have included a patch which activates it, which seems to work 
well here.

-- 

Oskar Sandberg
oskar at freenetproject.org
-------------- next part --------------
Index: libraries/javalib/java/net/Socket.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/net/Socket.java,v
retrieving revision 1.20
diff -r1.20 Socket.java
25c25
< 	this(address, port, true);
---
>     this(address, port, true);
29c29
< 	this(InetAddress.getByName(host), port, true);
---
>     this(InetAddress.getByName(host), port, true);
33c33,35
<     throw new kaffe.util.NotImplemented();
---
>     if (localAddr == null)
>         throw new NullPointerException();
>     connect(address, port, true, localAddr, localPort);
37c39
<     throw new kaffe.util.NotImplemented();
---
>     this(InetAddress.getByName(host), port, localAddr, localPort);
44c46
< 	this(InetAddress.getByName(host), port, stream);
---
>     this(InetAddress.getByName(host), port, stream);
51,62c53,71
< 	impl = factory.createSocketImpl();
< 	try {
< 		impl.create(stream);
< 		impl.connect(address, port);
< 	} catch (IOException ioe) {
< 		try {
< 			impl.close();
< 		}
< 		catch (IOException _) {
< 		}
< 		throw ioe;
< 	}
---
>     connect(address, port, stream, null, 0);
> }
> 
> private void connect(InetAddress address, int port, boolean stream,
>                      InetAddress localAddr, int localPort) throws IOException {
>     impl = factory.createSocketImpl();
>     try {
>         impl.create(stream);
>         if (localAddr != null)
>             impl.bind(localAddr, localPort);
>         impl.connect(address, port);
>     } catch (IOException ioe) {
>         try {
>             impl.close();
>         }
>         catch (IOException _) {
>         }
>         throw ioe;
>     }
99c108
< 		return (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR); 
---
>             return (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR); 


More information about the kaffe mailing list