Skip to content

Commit

Permalink
Merge pull request #160 from v-xiangs/convert-SocketAdaptor-to-Socket
Browse files Browse the repository at this point in the history
Convert socket adaptor to socket
  • Loading branch information
Suraiya Hameed authored Feb 28, 2017
2 parents 6e8dc59 + c086691 commit 369e5e0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2552,13 +2552,18 @@ private void findSocketUsingJavaNIO(InetAddress[] inetAddrs,
}
}

// if a channel was selected, make the necessary updates
// if a channel was selected, make the necessary updates
if (selectedChannel != null) {
// Note that this must be done after selector is closed. Otherwise,
// we would get an illegalBlockingMode exception at run time.
selectedChannel.configureBlocking(true);
selectedSocket = selectedChannel.socket();
//the selectedChannel has the address that is connected successfully
//convert it to a java.net.Socket object with the address
SocketAddress iadd = selectedChannel.getRemoteAddress();
selectedSocket = new Socket();
selectedSocket.connect(iadd);

result = Result.SUCCESS;

//close the channel since it is not used anymore
selectedChannel.close();
}
}

Expand Down

0 comments on commit 369e5e0

Please sign in to comment.