More corrections to java.net

Petter Reinholdtsen pere at games.no
Sun Aug 2 01:41:38 PDT 1998


Here are some more patches for java.net relative to the latest CVS
source:

  - Corrected interface of setSoTimeout from (boolean, int) to (int).
  - Implemented DatagramSocket.getLocalAddress()

After this fix, all my java.net test cases compiled. :-)

Index: ChangeLog
===================================================================
RCS file: /home/cvspublic/kaffe/ChangeLog,v
retrieving revision 1.82
diff -u -r1.82 ChangeLog
--- ChangeLog	1998/08/01 18:57:14	1.82
+++ ChangeLog	1998/08/02 08:34:26
@@ -1,4 +1,11 @@
-Sat Aug  1 12:16:30 1998  Petter Reinholdtsen <pere at games.no>
+Sun Aug  2 10:33:16 1998  Petter Reinholdtsen <pere at td.org.uit.no>
+
+	*libraries/javalib/java/net/Socket.java
+	libraries/javalib/java/net/DatagramSocket.java: Corrected
+	interface of setSoTimeout from (boolean, int) to (int).  Added
+	DatagramSocket.getLocalAddress()
+
+Sat Aug  1 12:16:30 1998  Petter Reinholdtsen <pere at td.org.uit.no>
 
 	* libraries/javalib/java/net/Socket.java: added getLocalAddress()
 	and fixed setLinger().
Index: libraries/javalib/java/net/DatagramSocket.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/net/DatagramSocket.java,v
retrieving revision 1.2
diff -u -r1.2 DatagramSocket.java
--- DatagramSocket.java	1998/07/31 04:05:07	1.2
+++ DatagramSocket.java	1998/08/02 08:35:35
@@ -38,8 +38,8 @@
 	impl.close();
 }
 
-public void setSoTimeout(boolean on, int timeout) throws SocketException {
-	impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(on ? timeout : 0));
+public void setSoTimeout(int timeout) throws SocketException {
+	impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
 }
 
 public int getSoTimeout() throws SocketException {
@@ -68,6 +68,17 @@
 
 public int getLocalPort() {
 	return localPort;
+}
+
+public InetAddress getLocalAddress() {
+	InetAddress localAddress;
+	try {
+		localAddress =
+			(InetAddress)impl.getOption(SocketOptions.SO_BINDADDR); 
+	} catch (Exception e) {
+		localAddress = InetAddress.anyLocalAddress;
+	}
+	return localAddress;
 }
 
 public synchronized void receive(DatagramPacket p) throws IOException {
Index: libraries/javalib/java/net/Socket.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/net/Socket.java,v
retrieving revision 1.3
diff -u -r1.3 Socket.java
--- Socket.java	1998/08/01 18:57:50	1.3
+++ Socket.java	1998/08/02 08:35:35
@@ -99,8 +99,8 @@
 	return ((Integer) impl.getOption(SocketOptions.SO_LINGER)).intValue();
 }
 
-public void setSoTimeout(boolean on, int timeout) throws SocketException {
-	impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(on ? timeout : 0));
+public void setSoTimeout(int timeout) throws SocketException {
+	impl.setOption(SocketOptions.SO_TIMEOUT, new Integer(timeout));
 }
 
 public int getSoTimeout() throws SocketException {
-- 
##>  Petter Reinholdtsen  <##  |  pere at td.org.uit.no


More information about the kaffe mailing list