I have a program using libpq on windows, and I use _open_osfhandle(PQsocket(cnxn), 0)
so that I can call select()
on it.
My problem is, libpq is closing the underlying socket in PQfinish()
so I get assert failures when calling _close()
on the value returned by _open_osfhandle()
Is there a way to close a CRT file descriptor, without also closing the underlying handle?
EDIT
The reason I need this, is because after about 512 connections, _open_osfhandle()
fails saying too many open files. Also, I tried _free_osfhnd
(I found it in close.cpp when visual studio showed me the source of the assert) and it still failed.