Filip, thanks for your reply.
You are correct that the server simply writes data, which we can format any way 
we like.
However, we were wondering whether Tomcat has any utilities/configurations to 
make it easier. E.g:

1) If we use multipart format (to separate between messages), does 
Tomcat/Apache have utilities to make it easier? Or should we hand-code the 
appropriate headers, separators, etc?

2) If we rely on "Content-length:" (to tell when one message ends and another 
begins), this header is usually automatically managed by Tomcat, so we'd have 
to ask Tomcat to manage it differently (otherwise, it might calculate one 
"content-length" for all messages put together, or it might omit it altogether 
and use "chunked" instead - which is also be an option, but then how do we tell 
tomcat to have a chunk per message).

Thanks again

--- On Mon, 1/3/11, Filip Hanik - Dev Lists <devli...@hanik.com> wrote:

From: Filip Hanik - Dev Lists <devli...@hanik.com>
Subject: Re: Comet and multipart
To: "Tomcat Users List" <users@tomcat.apache.org>
Date: Monday, January 3, 2011, 8:47 AM

On 1/3/2011 7:48 AM, sol myr wrote:
> Hi,
>
> We're implementing a CometServlet on top of Tomcat NIO connector, using "long 
> polling".
> Currently we're using the approach recommended by most tutorials: the client 
> opens a connection and waits for a message (for a configured timeout); if 
> such a message arrives, the client consumes it (e.g. presents it on screen), 
> then *closes* the http connection, and opens a new connection (to wait for 
> the next message).
>
> Unfortunately, we have a network performance problem with opening and closing 
> connections (our 3rd party proxy is good at keeping connections alive, but is 
> slow in negotiating new connections).
>
> So we'd like to keep the HTTP connection alive, and pass multiple messages on 
> the same connection. We were hoping to tell the messages apart based on 
> multipart format, or some other separator, or content length.
>
> Could anyone please tell whether that's supported on the TomcatServlet side?

yes, it is supported, as long as your client knows how to do it. On the 
server/servlet side, all you do is read the input stream byte by byte
you can create any type of protocol rules inside the HTTP message that it sends 
up
best
Filip




      

Reply via email to