harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Qiu" <sean.xx....@gmail.com>
Subject Re: [classlib]The bind operation of socket with SOCKS proxy
Date Tue, 09 Jan 2007 05:46:46 GMT
The problem is  the socksBind() has little relationship with bind();
IMHO, it should not appear in bind() at all.

Correct me if i was wrong.  :)

2007/1/8, Andrew Zhang <zhanghuangzhu@gmail.com>:
>
> On 1/8/07, Sean Qiu <sean.xx.qiu@gmail.com> wrote:
>
> > I mean that we remove both condition test about whether it uses a SOCKS
> > proxy to construct a socket.
> > Because whether a socket is or not using a SOCKS
> > proxy, the bind operation is the same.
> >
> > But i am still not quite sure about it, so the patch is not available
> yet.
> > The modification of the patch may look like:
> >
> > [1]java.net.Socket
> >
> > public void bind(SocketAddress localAddr) throws IOException {
> > ...
> >
> > //if (!NetUtil.usingSocks(proxy)) {
> > impl.bind(addr, port);
> > //}
> >
> > ...
> > }
>
>
> The original code above (without your fix) seems self-contradictory.
> Because PlainSocketImpl.bind starts as follow:
> if (NetUtil.usingSocks(proxy)) {
>             socksBind();
>             return;
>         }
>
> How could that happen if we have "if (!NetUtil.usingSocks(proxy))"
> statement
> before binding  ;)
>
>
> > [2]org.apache.harmony.luni.net.PlainSocketImpl
> >
> > protected void bind(InetAddress anAddr, int aPort) throws IOException {
> > //if (NetUtil.usingSocks (proxy)) {
> > //socksBind();
> > //return;
> > //}
>
>
> My feeling is that if test shows it should be binded, then we should bind
> it
> first and then do socksBind() which connects to socks server, which means
> to
> put "socksBind()" at the end of this method.  But I didn't write a test
> to verify my thought yet. :-)
>
>
> > It can pass the test.
> > But i am not sure it is the most appropriate way.
> > Thank you for any suggestion.   :)
> >
> > 2007/1/8, Andrew Zhang <zhanghuangzhu@gmail.com>:
> > >
> > > On 1/8/07, Sean Qiu <sean.xx.qiu@gmail.com> wrote:
> > > >
> > > > In [1], the code means that if constructs a new Socket with Socks
> > > proxy,it
> > > > will not bind the address at all.So the address and port will remain
> > 0.
> > > > It causes the failure which was described in jira 2930 [2].So the
> > > > impl.bind(addr,port)
> > > > should be called to keep compatible with RI.
> > > >
> > > > But in [3], the method will call the socksBind() method which is
> used
> > to
> > > > implement the BIND request in SOCKS protocol.
> > > >
> > > > According to RFC 1928 [4], it said that "The BIND request is used in
> > > > protocols which require the client to accept connections from the
> > > > server.Itis expected that the client side of an application protocol
> > > > will use the
> > > > BIND request only to establish secondary connections after a primary
> > > > connection is established using CONNECT."
> > > > Obviously, this "BIND" in SOCKS Protocol is quite different from the
> > > > java.net.Socket.bind(SocketAddress) method.
> > > >
> > > > So in order to fix the bug, shall we remove both the condition test?
> > >
> > >
> > > Hi Sean, what does "test" here mean? Do you mean the if statement or
> > test
> > > cases?
> > >
> > > or could you please provide the patch so that it's easy for
> discussing?
> > >
> > > Is my
> > > > thought wrong?
> > > > Thoughts? Concerns?Comments? Thanks.:)
> > > >
> > > >
> > > > [1] //java.net.Socket
> > > > public void bind(SocketAddress localAddr) throws IOException {
> > > > ...
> > > > if (!NetUtil.usingSocks(proxy)) {
> > > > impl.bind(addr, port);
> > > > }
> > > > ...
> > > > }
> > > >
> > > > [2] http://issues.apache.org/jira/browse/HARMONY-2930
> > > >
> > > > [3] //org.apache.harmony.luni.net.PlainSocketImpl
> > > > protected void bind(InetAddress anAddr, int aPort) throws
> IOException
> > {
> > > > if (NetUtil.usingSocks(proxy)) {
> > > > socksBind();
> > > > return;
> > > > }
> > > > ...
> > > >
> > > > [4] http://rfc.net/rfc1928.html
> > > >
> > > > --
> > > > Sean Qiu
> > > >
> > > >
> > >
> > >
> > > --
> > > Best regards,
> > > Andrew Zhang
> > >
> > >
> >
> >
> > --
> > Sean Qiu
> >
> >
>
>
> --
> Best regards,
> Andrew Zhang
>
>


-- 
Sean Qiu

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message