Fixed the loop 
Now send message every 5minutes insted of inf messages after 5 min.
Fixed the link to the ODBC unit
The listener now correctly handles multiple messages on each socket.
The client now works but it has a serious memory leak.
Might have been corrected with the catch all safeguard in the loop.
I hope the server now works as it should.
Safe guard in loop to prevent memory leak from unhandled messages.