serversocket and proxy

Discussion in 'Java' started by cod3nam3, May 27, 2008.

  1. cod3nam3

    cod3nam3 Guest

    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?
     
    cod3nam3, May 27, 2008
    #1
    1. Advertising

  2. cod3nam3 wrote:
    > 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
     
    Silvio Bierman, May 27, 2008
    #2
    1. Advertising

  3. Silvio Bierman wrote:
    > cod3nam3 wrote:
    >> 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.
     
    Silvio Bierman, May 27, 2008
    #3
  4. cod3nam3

    EJP Guest

    cod3nam3 wrote:
    > 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.
     
    EJP, May 28, 2008
    #4
  5. Silvio Bierman wrote:
    > Silvio Bierman wrote:
    >> cod3nam3 wrote:
    >>> 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.
     
    Silvio Bierman, May 28, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Kuhn
    Replies:
    4
    Views:
    922
    Thomas Kuhn
    Jul 7, 2003
  2. Jason Teagle
    Replies:
    12
    Views:
    3,215
    Jason Teagle
    Oct 5, 2003
  3. Abraham Khalil
    Replies:
    1
    Views:
    515
    Knute Johnson
    Jan 26, 2004
  4. Thomas Hawkins

    Unusual ServerSocket Behaviour

    Thomas Hawkins, Jan 28, 2004, in forum: Java
    Replies:
    3
    Views:
    497
    Steve Horsley
    Jan 30, 2004
  5. JPractitioner
    Replies:
    3
    Views:
    381
    JPractitioner
    Feb 16, 2006
Loading...

Share This Page