aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-08-11 03:07:59 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-08-11 03:07:59 +0000
commit366a0fd8043a51bcd6e2f81004cde8d9607331e2 (patch)
treebb40296aa76ff73c6371d67ebd7120a12196a32b /libjava/java
parentedd71f0f6cd9a303874d4a3e604a5f5fe760a975 (diff)
downloadgcc-366a0fd8043a51bcd6e2f81004cde8d9607331e2.zip
gcc-366a0fd8043a51bcd6e2f81004cde8d9607331e2.tar.gz
gcc-366a0fd8043a51bcd6e2f81004cde8d9607331e2.tar.bz2
natPlainSocketImpl.cc (bind): Don't go to error case when errno not set.
* java/net/natPlainSocketImpl.cc (bind): Don't go to error case when errno not set. (connect): Likewise. (accept): Likewise. (getOption): Likewise. * java/net/natPlainDatagramSocketImpl.cc (bind): Don't go to error case when errno not set. (peek): Likewise. (send): Likewise. (receive): Likewise. (mcastGrp): Likewise. (setOption): Likewise. (getOption): Likewise. From-SVN: r35617
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/net/natPlainDatagramSocketImpl.cc21
-rw-r--r--libjava/java/net/natPlainSocketImpl.cc21
2 files changed, 27 insertions, 15 deletions
diff --git a/libjava/java/net/natPlainDatagramSocketImpl.cc b/libjava/java/net/natPlainDatagramSocketImpl.cc
index fe83b10..2fac17e 100644
--- a/libjava/java/net/natPlainDatagramSocketImpl.cc
+++ b/libjava/java/net/natPlainDatagramSocketImpl.cc
@@ -199,7 +199,8 @@ java::net::PlainDatagramSocketImpl::bind (jint lport,
}
#endif
else
- goto error;
+ throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
+
if (::bind (fnum, ptr, len) == 0)
{
socklen_t addrlen = sizeof(u);
@@ -245,7 +246,8 @@ java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *i)
}
#endif
else
- goto error;
+ throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
+
i->address = raddr;
return rport;
error:
@@ -281,7 +283,8 @@ java::net::PlainDatagramSocketImpl::send (java::net::DatagramPacket *p)
}
#endif
else
- goto error;
+ throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
+
if (::sendto (fnum, (char *) dbytes, p->getLength(), 0, ptr, len) >= 0)
return;
error:
@@ -337,7 +340,8 @@ java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *p)
}
#endif
else
- goto error;
+ throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
+
p->setAddress (new InetAddress (raddr, NULL));
p->setPort (rport);
p->setLength ((jint) retlen);
@@ -412,7 +416,8 @@ java::net::PlainDatagramSocketImpl::mcastGrp (java::net::InetAddress *inetaddr,
}
#endif
else
- goto error;
+ throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
+
if (::setsockopt (fnum, level, opname, ptr, len) == 0)
return;
error:
@@ -507,7 +512,9 @@ java::net::PlainDatagramSocketImpl::setOption (jint optID,
}
#endif
else
- goto error;
+ throw
+ new java::net::SocketException (JvNewStringUTF ("invalid length"));
+
if (::setsockopt (fnum, level, opname, ptr, len) != 0)
goto error;
return;
@@ -576,7 +583,7 @@ java::net::PlainDatagramSocketImpl::getOption (jint optID)
}
#endif
else
- goto error;
+ throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
localAddress = new java::net::InetAddress (laddr, NULL);
}
return localAddress;
diff --git a/libjava/java/net/natPlainSocketImpl.cc b/libjava/java/net/natPlainSocketImpl.cc
index 18fd74b..66cbf97 100644
--- a/libjava/java/net/natPlainSocketImpl.cc
+++ b/libjava/java/net/natPlainSocketImpl.cc
@@ -153,7 +153,7 @@ java::net::PlainSocketImpl::bind (java::net::InetAddress *host, jint lport)
}
#endif
else
- goto error;
+ throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
// Enable SO_REUSEADDR, so that servers can reuse ports left in TIME_WAIT.
::setsockopt(fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i));
@@ -201,17 +201,20 @@ java::net::PlainSocketImpl::connect (java::net::InetAddress *host, jint rport)
}
#endif
else
- goto error;
+ throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
+
if (::connect (fnum, ptr, len) != 0)
goto error;
address = host;
port = rport;
// A bind may not have been done on this socket; if so, set localport now.
if (localport == 0)
- if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
- localport = ntohs (u.address.sin_port);
- else
- goto error;
+ {
+ if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
+ localport = ntohs (u.address.sin_port);
+ else
+ goto error;
+ }
return;
error:
char* strerr = strerror (errno);
@@ -272,7 +275,8 @@ java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s)
}
#endif
else
- goto error;
+ throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
+
s->fnum = new_socket;
s->localport = localport;
s->address = new InetAddress (raddr, NULL);
@@ -445,7 +449,8 @@ java::net::PlainSocketImpl::getOption (jint optID)
}
#endif
else
- goto error;
+ throw
+ new java::net::SocketException (JvNewStringUTF ("invalid family"));
localAddress = new java::net::InetAddress (laddr, NULL);
}
return localAddress;