<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
Hi all,
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">I'm Terry and I'm from the mssql-jdbc driver team. I'd like to propose some changes to JDK that would allow for keepalive extended socket options support for Windows in order maintain feature parity within the mssql-jdbc driver project.
 Currently, keepalive options are only supported on Linux and Mac.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">I did some research on this and there are some points to consider when implementing this change. On Windows, to set the keepalive values, we do so natively through the SIO_KEEPALIVE_VALS control code. The problem however is that
 the API requires that keepalive time and interval be configured at the same time. So, the semantics of SIO_KEEPALIVE_VALS are the same as TCP_KEEPIDLE + TCP_KEEPINTERVAL on other platforms -- setting keepalive values through SIO_KEEPALIVE_VALS is the same
 as setting it through TCP_KEEPIDLE + TCP_KEEPINTERVAL at once for other platforms. Another issue is that it's not possible to query the current keepalive values. However, there are system-wide default keepalive values. For keepalive time and interval on Windows,
 they're officially 2hrs and 1s respectively. But, it's possible these default values could be different.</div>
<div class="ContentPasted0"><br>
</div>
<div class="ContentPasted0">A possible idea I had was to introduce a new setOption that would set both keepalive values at the same time and reuse existing options in the JDK. So, something like below would be valid across all platforms.</div>
<div class="ContentPasted0">
<div><br>
</div>
<div>eg. socket.setOption(ExtendedSocketOptions.TCP_KEEPIDLE, 30, ExtendedSocketOptions.TCP_KEEPINTERVAL, 30);<br>
</div>
</div>
<div class="ContentPasted0"><br>
</div>
<div class="ContentPasted0"><span class="ContentPasted0 ContentPasted1" style="margin:0px">Another idea was to introduce a new Windows and JDK specific socket option. Earlier in the week I prematurely submitted a PR for this, apologies for that (I went through
 my org in order to submit a PR and thought dialog for something like this happens after).</span><br class="ContentPasted1">
</div>
<div class="ContentPasted0"><span class="ContentPasted0 ContentPasted1" style="margin:0px"><br>
</span></div>
<div class="ContentPasted0">Relevant links:</div>
<div class="ContentPasted0 ContentPasted3 ContentPasted4"><a href="https://bugs.openjdk.org/browse/JDK-8308593" id="LPlnk395645">https://bugs.openjdk.org/browse/JDK-8308593</a><br>
</div>
<div class="ContentPasted0 ContentPasted3 ContentPasted4"><span style="display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted5"><a href="https://learn.microsoft.com/en-us/windows/win32/winsock/sio-keepalive-vals" id="LPlnk932477">https://learn.microsoft.com/en-us/windows/win32/winsock/sio-keepalive-vals</a></span></div>
<div class="ContentPasted0"><span style="display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted6"><a href="https://learn.microsoft.com/en-us/windows/win32/winsock/sio-keepalive-vals#remarks" id="LPlnk967833">https://learn.microsoft.com/en-us/windows/win32/winsock/sio-keepalive-vals#remarks</a></span><br>
</div>
<div class="ContentPasted0"><span style="display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted7"><a href="https://stackoverflow.com/questions/14197347/how-to-query-socket-keep-alive-values-using-winsock/14198462#14198462" id="LPNoLPOWALinkPreview">https://stackoverflow.com/questions/14197347/how-to-query-socket-keep-alive-values-using-winsock/14198462#14198462</a></span><br>
</div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1"></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted8"><a href="https://stackoverflow.com/questions/18391341/reading-sio-keepalive-vals-fields-on-a-windows-socket-for-keepalive-idle-and-in" id="LPNoLPOWALinkPreview_1">https://stackoverflow.com/questions/18391341/reading-sio-keepalive-vals-fields-on-a-windows-socket-for-keepalive-idle-and-in</a></span><br>
</div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview_1 _EReadonly_1"></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div><span style="display: inline !important; background-color: rgb(255, 255, 255);" class="ContentPasted2">Any feedback and guidance on how this should be approached is appreciated.</span><br>
</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Thanks,</div>
Terry<br>
</div>
</body>
</html>