serversocket and proxy

C

cod3nam3

Hi, i have a small prog. where i am listining on a port for
connections:
Code:
        ServerSocket serversocket = null;
        listening = true;
        try
        {
            serversocket = new ServerSocket(64111);
            serversocket.setSoTimeout(1000);
        }
        catch(IOException ioexception)
        {

        }

        Socket socket = serversocket.accept();

The prog works fine outside of a proxy, fails behind one. I need
somehow to tell the socket to use a proxy on port 80. Someone have an
idea?
 
S

Silvio Bierman

cod3nam3 said:
Hi, i have a small prog. where i am listining on a port for
connections:
Code:
ServerSocket serversocket = null;
listening = true;
try
{
serversocket = new ServerSocket(64111);
serversocket.setSoTimeout(1000);
}
catch(IOException ioexception)
{

}

Socket socket = serversocket.accept();

The prog works fine outside of a proxy, fails behind one. I need
somehow to tell the socket to use a proxy on port 80. Someone have an
idea?


Use this code:

System.setProperty("socksProxyHost","some.socks.host");
System.setProperty("socksProxyPort","some.socks.port");

for a SOCKS proxy and

System.setProperty("http.proxyHost","some.http.proxy.host");
System.setProperty("http.proxyPort","some.http.proxy.port");

for a HTTP socket. The latter will of course only work with HTTP
requests as done via the URL class.

Regards,

Silvio Bierman
 
S

Silvio Bierman

Silvio said:
cod3nam3 said:
Hi, i have a small prog. where i am listining on a port for
connections:
Code:
ServerSocket serversocket = null;
listening = true;
try
{
serversocket = new ServerSocket(64111);
serversocket.setSoTimeout(1000);
}
catch(IOException ioexception)
{

}

Socket socket = serversocket.accept();

The prog works fine outside of a proxy, fails behind one. I need
somehow to tell the socket to use a proxy on port 80. Someone have an
idea?


Use this code:

System.setProperty("socksProxyHost","some.socks.host");
System.setProperty("socksProxyPort","some.socks.port");

for a SOCKS proxy and

System.setProperty("http.proxyHost","some.http.proxy.host");
System.setProperty("http.proxyPort","some.http.proxy.port");

for a HTTP socket. The latter will of course only work with HTTP
requests as done via the URL class.

Regards,

Silvio Bierman

I meant to say "HTTP proxy" instead of "HTTP socket" but you figured
that out yourself already, I guess.
 
E

EJP

cod3nam3 said:
The prog works fine outside of a proxy, fails behind one. I need
somehow to tell the socket to use a proxy on port 80.

You need to tell the *clients* about the proxy. Not this server code.
 
S

Silvio Bierman

Silvio said:
Silvio said:
cod3nam3 said:
Hi, i have a small prog. where i am listining on a port for
connections:
Code:
ServerSocket serversocket = null;
listening = true;
try
{
serversocket = new ServerSocket(64111);
serversocket.setSoTimeout(1000);
}
catch(IOException ioexception)
{

}

Socket socket = serversocket.accept();

The prog works fine outside of a proxy, fails behind one. I need
somehow to tell the socket to use a proxy on port 80. Someone have an
idea?


Use this code:

System.setProperty("socksProxyHost","some.socks.host");
System.setProperty("socksProxyPort","some.socks.port");

for a SOCKS proxy and

System.setProperty("http.proxyHost","some.http.proxy.host");
System.setProperty("http.proxyPort","some.http.proxy.port");
for a HTTP socket. The latter will of course only work with
HTTP requests as done via the URL class.

Regards,

Silvio Bierman

I meant to say "HTTP proxy" instead of "HTTP socket" but you figured
that out yourself already, I guess.

And as EJP noted: proxies are used from the client so my remarks are
meant for the client code connecting to your server.

You may be trying to do something that can only be achieved with a
reverse proxy but that is a completely different thing.

Please give us more details about what you are trying to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top