Code Review Request: 7096436: (sc) SocketChannel.connect fails on Windows 8 when channel configured non-blocking

Kurchi Subhra Hazra kurchi.subhra.hazra at oracle.com
Mon May 7 09:02:35 PDT 2012


Hi Alan,

>>
>> Bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7096436
>> Webrev: http://cr.openjdk.java.net/~khazra/7096436/webrev.00/
> Thanks for taking this one, the assumption has always been that the 
> connect would cause the socket to be bound immediately, if not already 
> bound.
>
> I agree with removing the code at L632-640 as that's where the 
> assumption is that the socket is implicitly bound. However if we 
> assign localAddress in the two places where we set the state to 
> ST_CONNECTED (connect and finishConnect) then it should solve the 
> issue. So unless I'm missing something (could very well b) then the 
> "bound" field shouldn't be needed. I also have concern about adding 
> this field because "state" and "localAddress" should already cover all 
> states. An alternative to not setting the localAddress after the 
> connection is establish is to change getLocalAddress to:

In this case what happens if someone calls:
sc.socket.bind(address);
sc.getLocalAddress();

I am guessing that state will still be ST_UNCONNECTED, and 
getLocalAddress will return null. Or am I missing something?


- Kurchi


>
> if (localAddress == null && (state == ST_CONNECTED))
> localAddress = Net.localAddress(fd);
>
> The downside to that is that on some platforms this can fail for the 
> case that the peer has closed the connection.
>
> -Alan.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20120507/83398fb1/attachment.html 


More information about the nio-dev mailing list