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 (Text):

            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. Advertisements

  2. cod3nam3 wrote:
    > Hi, i have a small prog. where i am listining on a port for
    > connections:
    >
    Code (Text):

    >         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. Advertisements

  3. Silvio Bierman wrote:
    > cod3nam3 wrote:
    >> Hi, i have a small prog. where i am listining on a port for
    >> connections:
    >>
    Code (Text):

    >>         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 (Text):

    >>>         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. Advertisements

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:
    1,135
    Thomas Kuhn
    Jul 7, 2003
  2. Jason Teagle
    Replies:
    12
    Views:
    4,525
    Jason Teagle
    Oct 5, 2003
  3. Abraham Khalil
    Replies:
    1
    Views:
    600
    Knute Johnson
    Jan 26, 2004
  4. JPractitioner
    Replies:
    3
    Views:
    502
    JPractitioner
    Feb 16, 2006
  5. Karsten Wutzke
    Replies:
    1
    Views:
    1,056
    Steven Simpson
    Aug 20, 2007
  6. Alejandro Molina

    Proxy and non Proxy configurations

    Alejandro Molina, Jul 15, 2004, in forum: ASP .Net Security
    Replies:
    0
    Views:
    274
    Alejandro Molina
    Jul 15, 2004
  7. Greg
    Replies:
    4
    Views:
    501
    Steven Simpson
    Aug 16, 2012
  8. Greg
    Replies:
    1
    Views:
    308
    Steven Simpson
    Aug 17, 2012
Loading...