connect()
Is it the right flow?
Your algorithm is correct for UDP. Take a look at these posts for more information: