aboutsummaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@albatross.co.nz>1999-08-03 00:30:53 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>1999-08-03 01:30:53 +0100
commit25fef12b66f0d50abd3d73bbd6c2e5ce96f1b78e (patch)
tree78d5c8974c85c8fca85f6fa82aca2c306a8999c9 /libjava
parenta0e4da0d17c4722c9c8e6c84acdac3ff4e33888b (diff)
downloadgcc-25fef12b66f0d50abd3d73bbd6c2e5ce96f1b78e.zip
gcc-25fef12b66f0d50abd3d73bbd6c2e5ce96f1b78e.tar.gz
gcc-25fef12b66f0d50abd3d73bbd6c2e5ce96f1b78e.tar.bz2
ServerSocket.java: Define ANY_IF.
* java/net/ServerSocket.java: Define ANY_IF. (ServerSocket (int,int)): Use ANY_IF instead of null to bind to all network interfaces. * java/net/DatagramSocket.java (DatagramSocket): ditto. * java/net/natPlainSocketImpl.cc (bind): Expect 0.0.0' instead of null. * java/net/natPlainDatagramSocketImpl (bind): Expect 0.0.0' instead of null. From-SVN: r28429
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog8
-rw-r--r--libjava/boehm.cc2
-rw-r--r--libjava/exception.cc2
-rw-r--r--libjava/java/net/DatagramSocket.java4
-rw-r--r--libjava/java/net/ServerSocket.java6
-rw-r--r--libjava/java/net/natPlainDatagramSocketImpl.cc12
-rw-r--r--libjava/java/net/natPlainSocketImpl.cc13
7 files changed, 23 insertions, 24 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index a456444..dcaae77 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -2,6 +2,14 @@
* boehm.cc (_Jv_RegisterFinalizer): Cast `meth' to GC_PTR.
* exception.cc (_Jv_Throw): Cast `_Jv_type_matcher' to __eh_matcher.
+ * java/net/ServerSocket.java: Define ANY_IF.
+ (ServerSocket (int,int)): Use ANY_IF instead of null to bind to
+ all network interfaces.
+ * java/net/DatagramSocket.java (DatagramSocket): ditto.
+ * java/net/natPlainSocketImpl.cc (bind): Expect `0.0.0.0' instead of
+ null.
+ * java/net/natPlainDatagramSocketImpl (bind): Expect `0.0.0.0'
+ instead of null.
1999-08-01 Alexandre Oliva <oliva@dcc.unicamp.br>
diff --git a/libjava/boehm.cc b/libjava/boehm.cc
index 3fc0a5d..f9e72ba 100644
--- a/libjava/boehm.cc
+++ b/libjava/boehm.cc
@@ -260,7 +260,7 @@ call_finalizer (GC_PTR obj, GC_PTR client_data)
void
_Jv_RegisterFinalizer (void *object, _Jv_FinalizerFunc *meth)
{
- GC_REGISTER_FINALIZER_NO_ORDER (object, call_finalizer, (GC_PTR)meth,
+ GC_REGISTER_FINALIZER_NO_ORDER (object, call_finalizer, (GC_PTR) meth,
NULL, NULL);
}
diff --git a/libjava/exception.cc b/libjava/exception.cc
index 0c6553f..9a0c796 100644
--- a/libjava/exception.cc
+++ b/libjava/exception.cc
@@ -147,7 +147,7 @@ _Jv_Throw (void *value)
_Jv_eh_alloc ();
ehinfo = *(__get_eh_info ());
}
- ehinfo->eh_info.match_function = (__eh_matcher)_Jv_type_matcher;
+ ehinfo->eh_info.match_function = (__eh_matcher) _Jv_type_matcher;
ehinfo->eh_info.language = EH_LANG_Java;
ehinfo->eh_info.version = 1;
ehinfo->value = value;
diff --git a/libjava/java/net/DatagramSocket.java b/libjava/java/net/DatagramSocket.java
index 3291efe..6f5e735 100644
--- a/libjava/java/net/DatagramSocket.java
+++ b/libjava/java/net/DatagramSocket.java
@@ -28,12 +28,12 @@ public class DatagramSocket
public DatagramSocket() throws SocketException
{
- this(0, null);
+ this(0, ServerSocket.ANY_IF);
}
public DatagramSocket(int port) throws SocketException
{
- this(port, null);
+ this(port, ServerSocket.ANY_IF);
}
public DatagramSocket(int port, InetAddress laddr) throws SocketException
diff --git a/libjava/java/net/ServerSocket.java b/libjava/java/net/ServerSocket.java
index 0d40bcc..95c9f35 100644
--- a/libjava/java/net/ServerSocket.java
+++ b/libjava/java/net/ServerSocket.java
@@ -25,6 +25,10 @@ public class ServerSocket
static SocketImplFactory factory;
SocketImpl impl;
+ static final byte[] zeros = {0,0,0,0};
+ /* dummy InetAddress, used to bind socket to any (all) network interfaces */
+ static final InetAddress ANY_IF = new InetAddress(zeros, null);
+
public ServerSocket (int port)
throws java.io.IOException
{
@@ -34,7 +38,7 @@ public class ServerSocket
public ServerSocket (int port, int backlog)
throws java.io.IOException
{
- this(port, backlog, null);
+ this(port, backlog, ANY_IF);
}
public ServerSocket (int port, int backlog, InetAddress bindAddr)
diff --git a/libjava/java/net/natPlainDatagramSocketImpl.cc b/libjava/java/net/natPlainDatagramSocketImpl.cc
index ec08d20..8ef7fd2 100644
--- a/libjava/java/net/natPlainDatagramSocketImpl.cc
+++ b/libjava/java/net/natPlainDatagramSocketImpl.cc
@@ -101,16 +101,10 @@ java::net::PlainDatagramSocketImpl::bind (jint lport,
// FIXME: prob. need to do a setsockopt with SO_BROADCAST to allow multicast.
union SockAddr u;
struct sockaddr *ptr = (struct sockaddr *) &u.address;
- jbyte *bytes = NULL;
// FIXME: Use getaddrinfo() to get actual protocol instead of assuming ipv4.
- int len = 4; // Initialize for INADDR_ANY in case host is NULL.
-
- if (host != NULL)
- {
- jbyteArray haddress = host->address;
- bytes = elements (haddress);
- len = haddress->length;
- }
+ jbyteArray haddress = host->address;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
if (len == 4)
{
diff --git a/libjava/java/net/natPlainSocketImpl.cc b/libjava/java/net/natPlainSocketImpl.cc
index 2e7f9d5..d42b821 100644
--- a/libjava/java/net/natPlainSocketImpl.cc
+++ b/libjava/java/net/natPlainSocketImpl.cc
@@ -71,17 +71,10 @@ java::net::PlainSocketImpl::bind (java::net::InetAddress *host, jint lport)
{
union SockAddr u;
struct sockaddr *ptr = (struct sockaddr *) &u.address;
- jbyte *bytes = NULL;
- // FIXME: Use getaddrinfo() to get actual protocol instead of assuming ipv4.
- int len = 4; // Initialize for INADDR_ANY in case host is NULL.
+ jbyteArray haddress = host->address;
+ jbyte *bytes = elements (haddress);
+ int len = haddress->length;
- if (host != NULL)
- {
- jbyteArray haddress = host->address;
- bytes = elements (haddress);
- len = haddress->length;
- }
-
if (len == 4)
{
u.address.sin_family = AF_INET;