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!

Socket Pool

Status
Not open for further replies.

developerinlondon

Programmer
Jan 11, 2003
196
GB
Does anyone know of any opensource Socket Pooling library I could use similar to the database poolings available from various places.
Basically I want to be able to limit the amount of connections that can be initiated through a socket at a specific time so that we dont hit the remote server at the same time more then once (notice the remote server only breaks down if we *initiate* a connection at the same time, once a connection is established it can handle it)
 
A ServerSocket queues connection requests to it. The default is something like 50 connections, so two together shouldn't present it with a problem.

Once a ServerSocket accepts a connection and passes you a Socket object, the conversation on the latter should happen on a new thread, leaving the ServerSocket to handle other requests.
 
I am using the URL class at the moment, so that I dont have to send in all the headers. Is there a simple way of using ServerSocket to replace URL?
do you mean the default 50 is the maximum amount of connections it tries to connect to *at a time* or it will still queue the 50? I have no control over the remote server that falls down, so have to make sure no two connections are made to that server at the exact same time.
 
If you only want to hit the server with one concurrent connection then just make the method that accesses the server synchronized.

PS, this forum is meant for J2EE questions - the Java forum is forum269

--------------------------------------------------
Free Database Connection Pooling Software
 
ok. but its a bit more complicated. we have a few threads being created from a particular instance of a servlet, *some* of them contact the same problem server. theres more instances of the servlet also, so out of all the threads its only certain ones that needs to be synchronized, others needs to be able to work parallely. i thought the easiest way to do this might have been to do it at socket level so that when any thread tries to access that specific socket it becomes synchronized?

[sorry, didnt realize J2EE is meant different... what would comprise J2EE question?]
 
Well why don't you have two methods - one synchronized and one not ? I think you're making a meal out of things unecessarily.

If there is a "problem" server, I would try to work out what the problem actually is.

A J2EE question would be one that is relevant to the J2EE API - such as EJB or JMS.

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top