You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Jeprotea <je...@gmail.com> on 2010/01/25 03:57:11 UTC

How to access socks4/5 proxy

Hi,Oleg
    I'm using HttpClient-4 and I'm trying to socket connections over a
special proxy. To do this I've consulted httpclient-4 tutorial,there are
only some simple explanations about
OperatedClientConnection,ClientConnectionOperator
and so on,however,i have no idea how to create sockets connection to a
socks4/5 proxy,if there needs others classes,and how about their call
relation,I'll be apreciated if you can give me special advices.I have known
so far:first,to creat a socket via SocketFactory, and then to get the socket
by OperatedClientConnection instances,finally, to create connections via
ClientConnectionOperator.
if i misunderstand it ?

please help

thanks,
Jeprotea

Re: How to access socks4/5 proxy

Posted by Jeprotea <je...@gmail.com>.
thanks for your advices! Oleg, i'll try it ~~

On Mon, Jan 25, 2010 at 5:24 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Mon, 2010-01-25 at 10:57 +0800, Jeprotea wrote:
> > Hi,Oleg
> >     I'm using HttpClient-4 and I'm trying to socket connections over a
> > special proxy. To do this I've consulted httpclient-4 tutorial,there are
> > only some simple explanations about
> > OperatedClientConnection,ClientConnectionOperator
> > and so on,however,i have no idea how to create sockets connection to a
> > socks4/5 proxy,if there needs others classes,and how about their call
> > relation,I'll be apreciated if you can give me special advices.I have
> known
> > so far:first,to creat a socket via SocketFactory, and then to get the
> socket
> > by OperatedClientConnection instances,finally, to create connections via
> > ClientConnectionOperator.
> > if i misunderstand it ?
> >
> > please help
> >
> > thanks,
> > Jeprotea
>
> SOCKS protocol works directly with Java Socket objects therefore does
> not require any special support on the HTTP transport level. If a Socket
> instance is configured to connect to a SOCKS proxy, no special
> configuration is required for HttpClient
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: How to access socks4/5 proxy

Posted by Jeprotea <je...@gmail.com>.
Thanks for your adevices again sincerely!  I'll see it according to your
suggestion.

On Wed, Jan 27, 2010 at 7:05 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> Jeprotea wrote:
>
>> hi,Oleg
>>   According to your advices, I've tried it,the code is like this(partial):
>> .................
>>  PlainSocketFactory sf = PlainSocketFactory.getSocketFactory();
>>   Socket socket = sf.createSocket();
>>   socket.connect(new InetSocketAddress(proxyHost,proxyPort), 0);
>>
>>   HttpParams params = new BasicHttpParams();
>>   params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 1000L);
>>
>>  sf.connectSocket(socket, targetHost, targetPort, null, -1, params);
>> .....
>>  however,there is not a established state,only:
>>
>>> netstat -ano | findstr "1080"
>>>
>>  TCP    10.64.44.176:1080      0.0.0.0:0              LISTENING
>> 2096
>>  TCP    10.64.44.176:2110      10.64.14.176:1080      SYN_SENT
>>  1440
>>
>>  if i 've made a mistake to create a socket connection for socks4 proxy
>> ,via
>> using above funcations included in httpclient-4,I am a novice,~~please
>> forgive my mistakes, could you give me special advices or exaples for it.
>>
>> thanks!
>>
>>
> Jeprotea
>
> I know next to nothing about the SOCKS protocol and am unable to help much.
> All I know is that SOCKS _should_ be completely transparent for the HTTP
> transport layer and should require no special configuration of HttpClient.
>
> For details see:
>
> http://en.wikipedia.org/wiki/SOCKS
> http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html
>
>
> Oleg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: How to access socks4/5 proxy

Posted by Oleg Kalnichevski <ol...@apache.org>.
Jeprotea wrote:
> hi,Oleg
>    According to your advices, I've tried it,the code is like this(partial):
> .................
>  PlainSocketFactory sf = PlainSocketFactory.getSocketFactory();
>    Socket socket = sf.createSocket();
>    socket.connect(new InetSocketAddress(proxyHost,proxyPort), 0);
> 
>    HttpParams params = new BasicHttpParams();
>    params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 1000L);
> 
>   sf.connectSocket(socket, targetHost, targetPort, null, -1, params);
> .....
>  however,there is not a established state,only:
>> netstat -ano | findstr "1080"
>   TCP    10.64.44.176:1080      0.0.0.0:0              LISTENING
> 2096
>   TCP    10.64.44.176:2110      10.64.14.176:1080      SYN_SENT        1440
> 
>  if i 've made a mistake to create a socket connection for socks4 proxy ,via
> using above funcations included in httpclient-4,I am a novice,~~please
> forgive my mistakes, could you give me special advices or exaples for it.
> 
> thanks!
> 

Jeprotea

I know next to nothing about the SOCKS protocol and am unable to help 
much. All I know is that SOCKS _should_ be completely transparent for 
the HTTP transport layer and should require no special configuration of 
HttpClient.

For details see:

http://en.wikipedia.org/wiki/SOCKS
http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html

Oleg

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: How to access socks4/5 proxy

Posted by Jeprotea <je...@gmail.com>.
hi,Oleg
   According to your advices, I've tried it,the code is like this(partial):
.................
 PlainSocketFactory sf = PlainSocketFactory.getSocketFactory();
   Socket socket = sf.createSocket();
   socket.connect(new InetSocketAddress(proxyHost,proxyPort), 0);

   HttpParams params = new BasicHttpParams();
   params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 1000L);

  sf.connectSocket(socket, targetHost, targetPort, null, -1, params);
.....
 however,there is not a established state,only:
>netstat -ano | findstr "1080"
  TCP    10.64.44.176:1080      0.0.0.0:0              LISTENING
2096
  TCP    10.64.44.176:2110      10.64.14.176:1080      SYN_SENT        1440

 if i 've made a mistake to create a socket connection for socks4 proxy ,via
using above funcations included in httpclient-4,I am a novice,~~please
forgive my mistakes, could you give me special advices or exaples for it.

thanks!

On Mon, Jan 25, 2010 at 5:24 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Mon, 2010-01-25 at 10:57 +0800, Jeprotea wrote:
> > Hi,Oleg
> >     I'm using HttpClient-4 and I'm trying to socket connections over a
> > special proxy. To do this I've consulted httpclient-4 tutorial,there are
> > only some simple explanations about
> > OperatedClientConnection,ClientConnectionOperator
> > and so on,however,i have no idea how to create sockets connection to a
> > socks4/5 proxy,if there needs others classes,and how about their call
> > relation,I'll be apreciated if you can give me special advices.I have
> known
> > so far:first,to creat a socket via SocketFactory, and then to get the
> socket
> > by OperatedClientConnection instances,finally, to create connections via
> > ClientConnectionOperator.
> > if i misunderstand it ?
> >
> > please help
> >
> > thanks,
> > Jeprotea
>
> SOCKS protocol works directly with Java Socket objects therefore does
> not require any special support on the HTTP transport level. If a Socket
> instance is configured to connect to a SOCKS proxy, no special
> configuration is required for HttpClient
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: How to access socks4/5 proxy

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2010-01-25 at 10:57 +0800, Jeprotea wrote:
> Hi,Oleg
>     I'm using HttpClient-4 and I'm trying to socket connections over a
> special proxy. To do this I've consulted httpclient-4 tutorial,there are
> only some simple explanations about
> OperatedClientConnection,ClientConnectionOperator
> and so on,however,i have no idea how to create sockets connection to a
> socks4/5 proxy,if there needs others classes,and how about their call
> relation,I'll be apreciated if you can give me special advices.I have known
> so far:first,to creat a socket via SocketFactory, and then to get the socket
> by OperatedClientConnection instances,finally, to create connections via
> ClientConnectionOperator.
> if i misunderstand it ?
> 
> please help
> 
> thanks,
> Jeprotea

SOCKS protocol works directly with Java Socket objects therefore does
not require any special support on the HTTP transport level. If a Socket
instance is configured to connect to a SOCKS proxy, no special
configuration is required for HttpClient 

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org