How to find socket fds opened by a process in windows

200 Views Asked by At

I have a client process running in windows (win 7/win 2008 server). The task is to enable keepalive for one of the socket it opened to get connected with a server. To make this connection i'm using windows API (connection to MSSQL server), from which i was unable to retrieve the socket fd it created.

1) What is the way to retrieve all the socket fds opened by a windows process (non python method, as the binary is a C++ based)

2) Is there any way to retrieve socket fd from the handle returned by the windows API SQLAllocHandle or SQLDriverConnect

Thanks

1

There are 1 best solutions below

2
On

You can't (AFAIK) and shouldn't (not supported) try to modify this on the client. SQL Server has a server-side configuration setting that controls this:

Keep Alive

This parameter (in milliseconds) controls how often TCP attempts to verify that an idle connection is still intact by sending a KEEPALIVE packet. The default is 30000 milliseconds.

https://technet.microsoft.com/en-us/library/ms190771(v=sql.105).aspx