my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Server/Client simple doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Server/Client simple doubt" Watch "Server/Client simple doubt" New topic
Author

Server/Client simple doubt

Julio Cesar Marques
Ranch Hand

Joined: Mar 21, 2009
Posts: 66
Hi guys!

Look, i have a simple question about client/server communication: Is this sequence correct?

client->request
server->acept
client->send
server->response
server->close connection
server->client connection (and again... again... again... in each object transmited)

=== OR ===

client->request
server->acept
client->send
server->response
client->send
server->response
client->send
server->response
client->send
server->response
server->close connection
server->client connection (finish here)

What is the best pratice?


Julio Cesar Lopes Marques
Sun Certified Java Developer 5, Sun Certified Java Programmer 5
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

Ah if it's a server and "closes connection" it shuts down - meaning clients can't connect. So second option is the correct approach.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Julio Cesar Marques
Ranch Hand

Joined: Mar 21, 2009
Posts: 66
is something like this:

imagine a first access for example (to get the list of data from .db file and populate JTable)

srv-->start
cli-->start
cli-->request list objects and populate JTable

... Now! What is better to happens?

after cli call ois.readObject() for example, i have to keep this conn open to wait for receive a new record, or i close the conn and when i need insert a new record i open conn again?
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2247
    
    7

Hi Julio, the best thing to do is to try doing what you said and see the impact. When you do close the connection, will it throw exception? If you reopen the connection does it make your code longer or complicated?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Server/Client simple doubt
 
Similar Threads
How to keep Java VM Alive
Problem writing to http URL with PUT (and HttpURLConnection)!
Help in creating a Concurrent Server
Java Http Server and Java Http Client
difference between Ports ?