Well, they will give you different levels of accuracy.
If you're only trying to find out whether anything is listening on the right port (and whether you can get to it) then connecting with a socket is the most appropriate way.
If you're trying to find out whether there's a web server listening on the port, then URLConnection is appropriate.
If you're trying to check that the expected web service is listening on the port, then making a web service call (preferably a cheap one with no side-effects - ideally created just for the sake of this "ping") is ideal.
Which do you want? Personally in most cases I'd prefer the third option - it gives the most information.