Solved

socket connection through proxy

Posted on 1998-10-14
1
865 Views
Last Modified: 2006-11-17
I am hooked on to the internet via a proxy server.I want to know how to open socket connection to a remote server (for eg java.sun.com) through a proxy server?
Note::
If i say Socket = new Socket("http://java.sun.com",80)
 I get an Exception "Route to host not found"
0
Comment
Question by:abhijitkhasnis
1 Comment
 
LVL 5

Accepted Solution

by:
fontaine earned 50 total points
ID: 1225789
The message you have is normal, because the first argument of the Socket constructor
has to be the host, i.e. java.sun.com, here. What you provided is the URL to the home
page of the java.sun.com Web site (served using the http protocol, the protocol used by
Web servers).

To connect through a proxy, you have to set the proxySet (...to true to inform the VM that you
want to connect through a proxy), proxyHost (to set to the proxy server host) and proxyPort
(to set to the proxy server port) properties. You have two options:

- Start the application using a command line in the following style :
   java -DproxySet=true -DproxyHost=myProxyServer.com -DproxyPort=80 MyJavaApp

- Use the Properties class:
   import java.util.properties;
   ...

  Properties systemSettings = System.getProperties();
  systemSettings.put("proxySet", true);
  systemSettings.put("proxyHost", "myProxyServer.com");
  systemSettings.put("proxyPort", "80");
  System.setProperties(systemSettings);
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now