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
This commit is contained in:
Tom Tromey 2000-08-11 03:07:59 +00:00 committed by Tom Tromey
parent edd71f0f6c
commit 366a0fd804
3 changed files with 43 additions and 15 deletions

View File

@ -1,3 +1,19 @@
2000-08-10 Tom Tromey <tromey@cygnus.com>
* 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.
2000-08-10 Bryce McKinlay <bryce@albatross.co.nz>
John Stracke <francis@ecal.com>

View File

@ -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;

View File

@ -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;