CPP: Keep alive of TCP server socket is not working

I’m using a PLCnect control as TCP server. The programming is done in C++. The TCP server works fine and accepts a connection from my Windows PC. I implement the socket with enabled Keep Alive signal. But when I disconnect my PC the connection is not terminated on the PLC. When I use the IEC61535 Function Blocks the connection is also disconnected on the PLC and I can reconnect. Can you help my to implement the same behavior in C++?

Hello pynl02, please see the attached cpp code, I think it will help you. If you have additionally questions, please contact me directly. Thanks & Best Regards Eduard

TCP_Server.pdf