I'm making a simple console client/server application with the WinSock2 api, but I need to make sure that the socket of the client closes properly when exiting the application. I have already tried to use a SetConsoleCtrlHandler
but that makes a thread where the main loop keeps running for 10 seconds.
Is there a way to close the socket when the user pressed the close button?