Networking Section Index | Page 7
What is a resource leak?
Garbage collection manages only memory, not other system resources.
If your Java program has plenty of free memory, garbage collection will not
be triggered automatically. Usually, however, there...more
How can I find the size of a remote HTML document?
You can use the getContentLength() method of
URLConnection. The example below shows you how.
Be aware that this will only work if the server accurately reports
the length of the file as part of ...more
How do I set the referer for a URLConnection?
Use the setRequestProperty() method of
URLConnection. The following example
shows how to do this properly:
import java.net.*;
import java.io.*;
public class RequestProperty {
public static ...more
How can I get URLConnection to bypass the proxy for certain addresses?
When using Sun's implementation of URL,
URLConnection, or HttpURLConnection,
to access an HTTP URL,
you can set the system property http.nonProxyHosts
to be a '|' separated list of hosts not to pr...more
Does a URLConnection using the FTP protocol support that protocol's RESTART command? If so, how can I initiate a restart?
As of the JDK 1.3, the included FTP protocol does not support the RESTART command.
How would you send a file over a socket connection?
If both ends of the connection knew exactly what was happening or expected (e.g. a single file with a constant filename, in the
simplest case), you could do something as simple as have one end re...more
What is the best way to launch the default e-mail editor from a Java Application. Can a new message be automatically sent to the editor?
There is no standard way to launch the default e-mail editor from a Java Application. If you were in a Java Applet, you could leverage the showDocument() method of AppletContext and pass it a ma...more
Can I cast the return object from URL.openConnection() to an HttpURLConnection in an applet?
Unfortunately, you can't. Both IE and NN version 4
and below return objects whose type is not HttpURLConnection or
a subclass thereof.
Strictly speaking openConnection() is only guaranteed to r...more
What is the default space name used for a JavaSpace, and how do I change this default?
Sun's implementation of JavaSpaces, called "Outrigger", uses the
default space name "JavaSpace". This can be changed by setting
the Sun-specific system property com.sun.jini....more
Where is the source code for all the examples in the <JINI_ROOT>/example directory of the Jini distribution?
All the Jini examples are part of the com.sun.jini.example package.
Although you might expect the source to be in the example directory, as is the
common practice for other Java API distributions,...more
Is HTTP proxy supported when using java.net.Socket instead of URLConnection? I need to use Socket so I can use setSoTimeout() for non-blocking reads. When I switched from URLConnection to Socket, the proxyHost and proxyPort system properties had no effect.
HTTP proxies perform a function specific to the HTTP protocol.
The HTTP protocol is implemented in whole by the class
HttpURLConnection - it is in this implementation
that the system properties r...more
How can I get InetAddress.getByName() to work through a proxy server?
The static method InetAddress.getByName()
uses the underlying OS's name service resolver to determine the
return value. Configuration of the resolver, i.e. telling the
resolver where and how to ...more
Are there any books which cover JavaSpaces?
JavaSpaces Principles, Patterns, and Practice (Addison-Wesley)
is the definitive treatment of JavaSpaces.
Professional Jini
(Wrox) covers JavaSpaces, although the primary focus is on Jini.
There i...more
Are there any mailing lists where I can ask questions about JavaSpaces?
There is a mailing list just for JavaSpaces. To subscribe, visit
http://archives.java.sun.com/archives/javaspaces-users.html
and follow the instructions there.
Because JavaSpaces is built on t...more
What is the difference between a SOCKS proxy and an HTTP proxy?
A SOCKS server is a general purpose proxy server that establishes
a TCP connection to another server on behalf of a client,
then routes all the traffic back and forth between the client and
the s...more