Connect two machines remotely using tcp connection

hey guys im in a great confusion i need how to connect two laptops via tcp which is in diffrent locations how do i connect can anybody say which protocol ill connect in programing not in the third party software like Anydesk