Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How many sockets are open to the web server?

Status
Not open for further replies.

igowi

Programmer
Sep 18, 2001
45
US
When accessing to same web server several times, Do I need to create this object several times? or I can use one object to do different requests?

For example,
I want to access to next I want to access to next I want to access to
I need to open new URL and create new HttpUrlConnection?

Please explain me how HttpURLConnection is working.

thanks.
 
Each is a different URL so each requires a different connection.
 
Thanks.
One more question
:)

HttpURLConnection establishes a socket connection to the web server?

First time,
I create an HttpURLConnection instance on and next
I create an instance on and next
I create an instance on
Every instance makes different socket connectin to the server?
or
It just uses one socket connection to the server.

I don't even know whether this is correct question or not.
 
Http is a 'connectionless' protocol so, yes. Each time you open a url connection, it establishes a temporary connection that allows you to read the data that the web server is going to send you. Once the data is read, the socket is closed. You do not maintain a persistent connection that allows to to continually send and receive information with the server.

The term 'connection' is being used in several ways in this context.
 
Thanks.

After I read and write to a server,
even though I didn't call this function
connection.disconnect()(connection is an instance of HttpURLConnection), automatically it's disconnected?

I should call the function disconnect() or it's doesn't matter?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top