I have a guess as to why Socket(host, port) fails with Connection refused. Does this make sense?
----
This is how I see the problem:
This works:
URL u = new URL(
http://java.sun.com);
URLConnection uc = u.openConnection();
But this does not work:
InetAddress addr = new InetAddress(
http://java.sun.com);
Socket s = new (addr, 80);
This is the exception:
java.net.ConnectException: Connection refused: connect
----
When I do this:
URL u = new URL(host);
URLConnection uc = u.openConnection();
System.out.println(uc.getClass());
I get this:
class sun.net.www.protocol.http.HttpURLConnection
----
Here is my explanation. Does this make sense?
sun.net.www.protocol.http.HttpURLConnection is a subclass of the abstract class URLConnection. Sun must implement the abstract method URLConnection.connect().
I am guessing, when Sun implements connect(), Sun is calling Socket(host, port) with host and port of the proxy server. Sun is negotiating with the proxy server using the HTTP protocol.
[ March 03, 2004: Message edited by: Marlene Miller ]