I don't know if this is a bug or a feature, but what's happening is that when your app exits with a return value of 0, it gets re-started by launchd. So, your app is running twice and therefore tries its TCP connection twice.
You can verify this by adding, say sleep(10)
just before you return from your main function; if you watch a process monitor, you'll see it launch, run for 10 seconds and then quit, get re-launched and run for another 10 seconds.
If you return a non-zero exit code or simply don't exit (as iOS apps usually don't), this won't happen.