TCP connection to private server (spark core as tcp client)

This post is old so you might have already found your answer?
If not - my example does everything in your list :