I didn't spent too much time but I can't find where ThreadMain is called from main module.
If I understand correctly, you tried to do the same as on mysql module and other modules you can found. In that case you manage a list of sockets to be polled at each frame or whatever timeframe you want. I can't find that.
Another question is if you have tried your calls to listent/recv/etc on udp sockets. They work slightly different and could broke how you check for incoming data.