I briefly went over socket program:
I don't see a single rung comment - how do you expect people to understand it?
You may remember and understand it now, but you will not remember it in two years.
- Rung 28 - you can't cascade messages like this, at least wait until one done before triggering the next one.
- Rung 29 - you are executing Delete All after you deleted indifidula sockets - Why? you do individual or All, but not both
- Rung 28 and rung 33 use the same message control - this is illegal, same for other 3 delete messages.
I see some message control words used 3 times (HMIR_DELETE_SOCKETMSG), so it makes no sence to debug the rest 140+ rungs until you corrected simple things - sorry but this is poorly written socket program.
Get sample code from Knowledgebase instead - it will save you time.