That's not how TCP sockets work. Every byte is sent at the most once. If messages are arriving twice it's because you're sending them twice. Are you 100% sure you're not sending the same messages twice?