Commit d0c97db6 by Michael Koch Committed by Michael Koch

2002-09-12 Michael Koch <konqueror@gmx.de>

	* java/net/DatagramSocketImpl.jav
	(peekData): New method.
	* java/net/PlainDatagramSocketImpl.java
	(peekData): New method.
	* java/net/natPlainDatagramSocketImpl.cc
	(peekData): New method.
	* java/net/URLConnection
	(getPermission): New method.
	(addRequestProperty): New method.
	(getRequestProperties): New method.
	(guessContentTypeFromStream): New method, not really implemented.
	(URLConnection): Added/updated documentation.
	(connect): Added/updated documentation.
	(getURL): Added/updated documentation.
	(getContentLength): Added/updated documentation.
	(getContentType: Added/updated documentation.
	(getContentEncoding): Added/updated documentation.
	(getExpiration): Added/updated documentation.
	(getDate): Added/updated documentation.
	(getLastModified): Added/updated documentation.
	(getHeaderField): Added/updated documentation.
	(getHeaderFields): Added/updated documentation.
	(getHeaderFieldInt): Added/updated documentation.
	(getHeaderFieldDate): Added/updated documentation.
	(getHeaderFieldKey): Added/updated documentation.
	(getContent): Added/updated documentation.
	(getInputStream): Added/updated documentation.
	(getOutputStream): Added/updated documentation.
	(toString): Added/updated documentation.
	(setDoInput): Added/updated documentation.
	(getDoInput): Added/updated documentation.
	(setDoOutput): Added/updated documentation.
	(getDoOutput): Added/updated documentation.
	(setAllowUserInteraction): Added/updated documentation.
	(getAllowUserInteraction): Added/updated documentation.
	(setDefaultAllowUserInteraction): Added/updated documentation.
	(getDefaultAllowUserInteraction): Added/updated documentation.
	(setUseCaches): Added/updated documentation.
	(getUseCaches): Added/updated documentation.
	(setIfModifiedSince): Added/updated documentation.
	(getIfModifiedSince): Added/updated documentation.
	(getDefaultUseCaches): Added/updated documentation.
	(setDefaultUseCaches): Added/updated documentation.
	(setRequestProperty): Added/updated documentation.
	(getRequestProperty): Added/updated documentation.
	(setDefaultRequestProperty): Added/updated documentation.
	(getDefaultRequestProperty): Added/updated documentation.
	(setContentHandlerFactory): Added/updated documentation.

From-SVN: r57049
parent 35aff10b
2002-09-12 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocketImpl.jav
(peekData): New method.
* java/net/PlainDatagramSocketImpl.java
(peekData): New method.
* java/net/natPlainDatagramSocketImpl.cc
(peekData): New method.
* java/net/URLConnection
(getPermission): New method.
(addRequestProperty): New method.
(getRequestProperties): New method.
(guessContentTypeFromStream): New method, not really implemented.
(URLConnection): Added/updated documentation.
(connect): Added/updated documentation.
(getURL): Added/updated documentation.
(getContentLength): Added/updated documentation.
(getContentType: Added/updated documentation.
(getContentEncoding): Added/updated documentation.
(getExpiration): Added/updated documentation.
(getDate): Added/updated documentation.
(getLastModified): Added/updated documentation.
(getHeaderField): Added/updated documentation.
(getHeaderFields): Added/updated documentation.
(getHeaderFieldInt): Added/updated documentation.
(getHeaderFieldDate): Added/updated documentation.
(getHeaderFieldKey): Added/updated documentation.
(getContent): Added/updated documentation.
(getInputStream): Added/updated documentation.
(getOutputStream): Added/updated documentation.
(toString): Added/updated documentation.
(setDoInput): Added/updated documentation.
(getDoInput): Added/updated documentation.
(setDoOutput): Added/updated documentation.
(getDoOutput): Added/updated documentation.
(setAllowUserInteraction): Added/updated documentation.
(getAllowUserInteraction): Added/updated documentation.
(setDefaultAllowUserInteraction): Added/updated documentation.
(getDefaultAllowUserInteraction): Added/updated documentation.
(setUseCaches): Added/updated documentation.
(getUseCaches): Added/updated documentation.
(setIfModifiedSince): Added/updated documentation.
(getIfModifiedSince): Added/updated documentation.
(getDefaultUseCaches): Added/updated documentation.
(setDefaultUseCaches): Added/updated documentation.
(setRequestProperty): Added/updated documentation.
(getRequestProperty): Added/updated documentation.
(setDefaultRequestProperty): Added/updated documentation.
(getDefaultRequestProperty): Added/updated documentation.
(setContentHandlerFactory): Added/updated documentation.
(guessContentTypeFromName): Added/updated documentation.
(getFileNameMap): Added/updated documentation.
(setFileNameMap): Added/updated documentation.
2002-09-11 Michael Koch <konqueror@gmx.de> 2002-09-11 Michael Koch <konqueror@gmx.de>
* java/net/Socket.java * java/net/Socket.java
......
...@@ -112,6 +112,20 @@ public abstract class DatagramSocketImpl implements SocketOptions ...@@ -112,6 +112,20 @@ public abstract class DatagramSocketImpl implements SocketOptions
protected abstract int peek(InetAddress i) throws IOException; protected abstract int peek(InetAddress i) throws IOException;
/** /**
* Takes a peek at the next packet received. This packet is not consumed.
* With the next peekData/receive operation this packet will be read again.
*
* @param p The DatagramPacket to fill in with the data sent.
*
* @return The port number of the sender of the packet.
*
* @exception IOException If an error occurs
*
* @since 1.4
*/
protected abstract int peekData (DatagramPacket p) throws IOException;
/**
* Transmits the specified packet of data to the network. The destination * Transmits the specified packet of data to the network. The destination
* host and port should be encoded in the packet. * host and port should be encoded in the packet.
* *
......
...@@ -65,6 +65,7 @@ class PlainDatagramSocketImpl extends DatagramSocketImpl ...@@ -65,6 +65,7 @@ class PlainDatagramSocketImpl extends DatagramSocketImpl
throws SocketException; throws SocketException;
protected native void create() throws SocketException; protected native void create() throws SocketException;
protected native int peek(InetAddress i) throws IOException; protected native int peek(InetAddress i) throws IOException;
protected native int peekData (DatagramPacket dp) throws IOException;
protected native void setTimeToLive(int ttl) throws IOException; protected native void setTimeToLive(int ttl) throws IOException;
protected native int getTimeToLive() throws IOException; protected native int getTimeToLive() throws IOException;
protected native void send(DatagramPacket p) throws IOException; protected native void send(DatagramPacket p) throws IOException;
......
...@@ -93,6 +93,13 @@ java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *) ...@@ -93,6 +93,13 @@ java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *)
JvNewStringLatin1 ("DatagramSocketImpl.peek: unimplemented")); JvNewStringLatin1 ("DatagramSocketImpl.peek: unimplemented"));
} }
jint
java::net::PlainDatagramSocketImpl::peekData(java::net::DatagramPacket *)
{
throw new java::io::IOException (
JvNewStringLatin1 ("DatagramSocketImpl.peekData: unimplemented"));
}
void void
java::net::PlainDatagramSocketImpl::close () java::net::PlainDatagramSocketImpl::close ()
{ {
...@@ -295,6 +302,68 @@ java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *i) ...@@ -295,6 +302,68 @@ java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *i)
throw new java::io::IOException (JvNewStringUTF (strerr)); throw new java::io::IOException (JvNewStringUTF (strerr));
} }
jint
java::net::PlainDatagramSocketImpl::peekData(java::net::DatagramPacket *p)
{
// FIXME: Deal with Multicast and if the socket is connected.
union SockAddr u;
socklen_t addrlen = sizeof(u);
jbyte *dbytes = elements (p->getData());
ssize_t retlen = 0;
// FIXME: implement timeout support for Win32
#ifndef WIN32
// Do timeouts via select since SO_RCVTIMEO is not always available.
if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
{
fd_set rset;
struct timeval tv;
FD_ZERO(&rset);
FD_SET(fnum, &rset);
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
int retval;
if ((retval = _Jv_select (fnum + 1, &rset, NULL, NULL, &tv)) < 0)
goto error;
else if (retval == 0)
throw new java::io::InterruptedIOException ();
}
#endif /* WIN32 */
retlen =
::recvfrom (fnum, (char *) dbytes, p->getLength(), MSG_PEEK, (sockaddr*) &u,
&addrlen);
if (retlen < 0)
goto error;
// FIXME: Deal with Multicast addressing and if the socket is connected.
jbyteArray raddr;
jint rport;
if (u.address.sin_family == AF_INET)
{
raddr = JvNewByteArray (4);
memcpy (elements (raddr), &u.address.sin_addr, 4);
rport = ntohs (u.address.sin_port);
}
#ifdef HAVE_INET6
else if (u.address.sin_family == AF_INET6)
{
raddr = JvNewByteArray (16);
memcpy (elements (raddr), &u.address6.sin6_addr, 16);
rport = ntohs (u.address6.sin6_port);
}
#endif
else
throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
p->setAddress (new InetAddress (raddr, NULL));
p->setPort (rport);
p->setLength ((jint) retlen);
return rport;
error:
char* strerr = strerror (errno);
throw new java::io::IOException (JvNewStringUTF (strerr));
}
// Close(shutdown) the socket. // Close(shutdown) the socket.
void void
java::net::PlainDatagramSocketImpl::close () java::net::PlainDatagramSocketImpl::close ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment