Created
June 10, 2015 12:40
-
-
Save mercdev/d5c9d333cb51f9ed3a0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void SetKeepAliveIOControl(Socket socket, uint interval, uint retryInterval, bool enabled) | |
{ | |
int size = sizeof(UInt32); | |
uint on = enabled ? (uint)1 : (uint)0; | |
byte[] inArray = new byte[size * 3]; | |
Array.Copy(BitConverter.GetBytes(on), 0, inArray, 0, size); | |
Array.Copy(BitConverter.GetBytes(interval), 0, inArray, size, size); | |
Array.Copy(BitConverter.GetBytes(retryInterval), 0, inArray, size * 2, size); | |
socket.IOControl(IOControlCode.KeepAliveValues, inArray, null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment