Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Server/Client simple doubt

 
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah if it's a server and "closes connection" it shuts down - meaning clients can't connect. So second option is the correct approach.
 
Julio Cesar Marques
Ranch Hand
Posts: 80
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic