Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

client server communication problem through URLConnection

Thread view: 
itpartha@yahoo.com - 14 Feb 2006 11:22 GMT
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.
feradz@gmail.com - 14 Feb 2006 11:59 GMT
Hi, here I can not understand what exactly is your goal in your
clinet-server application but will try to give you an advice that may
work out.

Now, It would be better to server each client with a separate. When a
server sockets accepts a client connection, create a separate thread
that will deal with that particular client requests. So if there are 5
clients connected to the server simultaneously, there will be 5 threads
in the server app that will run simultaneously and serve each client.

There is a simple example for this on sun's site
http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html

I home that my answer was relevant to your problem.
Ferad Zyulkyarov
timjowers@gmail.com - 14 Feb 2006 14:27 GMT
I think the connection is identified by a four tuple.
(srcIP,srcPort,destIP,destPort)

You cannot have two connections with identical four tuples. The network
drivers of your OS require uniqueness o know to which app to route the
packet.

Perhaps your client, srcIP, is always using the same port, srcPort,
when it attempts to connect? Otherwise surely Java allows more than one
connection from a client. Write a simple test and let us know.

TimJowers
timjowers@gmail.com - 14 Feb 2006 14:30 GMT
Oh yeah,  look at the HTTP/1.1 keepalive in URLConnection. It tells the
server to keep the connection open rather than close it. Maybe your way
would be to turn it off.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.