I
itpartha
Dear all
I am implementing a general purpose chat software using Core
Java. The client is an applet that uses HttpURLConnection to
communicate to the server. Currently the client periodically makes
request to the server though most of the time it has nothing to send,
and the server responds though sometime it has nothing to reply and
closes the connection. The identity of the clent as well as the message
to send is attached to the request header. But periodically hitting the
server makes the proxy slow responding to other users.
I tried to make it like that whenever the client has something
to send it requests the server, the server then verifies that whether
the incoming connection request is coming from a client that has a
previous connection active. If so then it first closes the first
connection, then process the new request data. Now on, the server uses
the new connection to send data to that client and keeps the connection
alive until the next request reaches. The will certainly require less
traffic.
But the problem is that while the server has a running
connection to a client, it blocks reading from other connections from
the client until the previous connection is closed, while without
reading from the new connection the server can't find the client's
identity and close the previous alive connection.
Somebody please help me to find the solution.
I am implementing a general purpose chat software using Core
Java. The client is an applet that uses HttpURLConnection to
communicate to the server. Currently the client periodically makes
request to the server though most of the time it has nothing to send,
and the server responds though sometime it has nothing to reply and
closes the connection. The identity of the clent as well as the message
to send is attached to the request header. But periodically hitting the
server makes the proxy slow responding to other users.
I tried to make it like that whenever the client has something
to send it requests the server, the server then verifies that whether
the incoming connection request is coming from a client that has a
previous connection active. If so then it first closes the first
connection, then process the new request data. Now on, the server uses
the new connection to send data to that client and keeps the connection
alive until the next request reaches. The will certainly require less
traffic.
But the problem is that while the server has a running
connection to a client, it blocks reading from other connections from
the client until the previous connection is closed, while without
reading from the new connection the server can't find the client's
identity and close the previous alive connection.
Somebody please help me to find the solution.