HttpClient, keep it persistent

Hi guys,

I have this little application that will wait for data. When data is received, it will send it to an http server. What I want to do is not always create a new connection for new information to send, since it will always be sent to the same server.

Here's something I have thought of:

In the constructor:
mHttpClient = new HttpClient(new MultiThreadedHttpConnectionManager());

When I will loop for new data, I will then create a new PostMethod everytime and send it:

PostMethod post = new PostMethod("http://server:1234/application/...");
mHttpClient.execute(post);

Doing this, wouldn't the PostMethod create a new connection to the server? Would there be a way to connect to the application and only give it the path and arguments afterwards?

I will always be connecting to "http://server:1234/application". When I will receive new data, I will send it to a path, like "/home/users/myself/file.txt" (the whole path would be: http://server:1234/application/home/users/myself/file.txt). Is there a way to do this so that it would not create a new connection every time but that it would just keep connected to it and just send further data?

Ex: I would like it to do something like this (I know it's wrong, but just to let you understand better) :
HttpClient client = new HttpClient("http", "server", "1234", "/application");
PostMethod post = new PostMethod("/home/users/myself/file.txt");
// here add arguments to the post
client.execute(post);

Thanks a lot,

-Jeremie
[1618 byte] By [jeremiorama] at [2007-11-20 10:05:56]
# 1 Re: HttpClient, keep it persistent
I may be wrong, but as I understand it, recommended practice for optimum server performance is to hold connections for the minimum practical time. Your objective runs counter to this.

That language is an instrument of human reason, and not merely a medium for the expression of thought, is a truth generally admitted...
G. Boole
dlorde at 2007-11-10 2:14:34 >
# 2 Re: HttpClient, keep it persistent
Well, yes, but my application will send data stream continuously to the server. The server was created for this. The application that will send the data must be fast though.

Any idea?
jeremiorama at 2007-11-10 2:15:39 >