This will repeat forever, creating more and more sockets.

I suspect you only want to open the socket once, simply remove it from the while(true) loop.