Presumably, you mean the java library "URLConnection" versus or raw sockets.
Since connecting to URLs uses sockets internally, logically, sockets should be slightly faster, since http makes all socket calls plus some overhead when processing the full protocol.
In practice, I would expect a very small difference. If you create your own socket interface, you will need to do most of the extra processing done using the URL connection to make the socket connection workable and reliable.
Also, the "URLConnection" java library was probably written by programmers who are better than you or me. Of course, 10 years have been discovered on most errors. So, why not take advantage of this skill and experience and use the simpler URLConnection.
source share