If the server supports a protocal that URL recognizes (ftp or http), you can use URL to create a URLConnection to it(which really winds up being a socket connection usually to port 80 for http and port 21 for ftp on the server). It will take care of some of the protocal specific communiction for you.
Sockets can be used at any time. If you use a socket client to contact an http server, you have to handle some of the details that URL already does (like sending a get when you request a page). Using a socket does allow you to handle the communication in your own way if you don't wish to use one of the established protocals.
For more detail check out
Custom Networking tutorial