Which is fast URLConnection or Socket

前端 未结 5 761
野的像风
野的像风 2021-01-06 07:45

For getting data from remote url which connection type will work fast URLConnection or Socket.

5条回答
  •  半阙折子戏
    2021-01-06 07:59

    It does not matter which one is faster both of these have different purposes. A socket is an endpoint for communication between two machines and need to access different protocol. Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web. A resource can be something as simple as a file or a directory, or it can be a reference to a more complicated object, such as a query to a database or to a search engine. In short if you need to communicate with the other machine or device implement socket and if you want to read data from server use URLconnection.

    Happy Coding :D

提交回复
热议问题