• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: Clients' connections

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello to all,
Does anyone know how can I control the connection of clients on the server side? I've tried to use RMISocketFactory, but it didn't work. I would like to know if one client is still connected or not.

Thanks,
Fl�vio.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fl�vio,
If you create a new connection for each client (use a connection Factory), then you will be able to have the connection class implement the Unreferenced interface. When that connection is dropped (deliberate disconnection or through network fault / client crash) your unreferenced method will be called.
Regards, Andrew
 
Flavio Nobili
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Andrew,
I've tried unsing the UnicastRemoteObject interface, but it's not really worked, and I don't understand why.
I have a factory class, registered in the RMI runtime, which gives a new instance of the Database class for each client that calls getDatabase method. The Database class is a remote object that implements the UnicastRemoteObject interface. The unreferenced method just displays something. So, when a client is closed something should be displayed on the screen, but it doesn't happen. Do you know what is wrong?


Regards,
Fl�vio
[ February 04, 2004: Message edited by: Fl�vio Fran�a ]
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried waiting 10 minutes? I think the default timeout for this is something around that time, so if you haven't changed it you'll have to wait!
Steve
 
Flavio Nobili
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Stephen,
I've tried wainting 10 minutes, and it works this way. Thanks for helping. Do you know how I change this timeout?

Regards,
Flavio
 
Stephen Galbraith
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, sorry
but I think you have to set the timeout for the underlying socket
(but again don't ask me how - I've just got my RMI up and running, need to refactor majorly though At the minute I'm back to re-working the wait and notify on my record locking to be @ the record level - is there no end???)
Steve
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Flavio,

I've tried wainting 10 minutes, and it works this way. Thanks for helping. Do you know how I change this timeout?


You can try:
System.setProperty("java.rmi.dgc.leaseValue", "10000");
(Or set it at the command line)
This will set the timeout to 10 seconds - very useful when testing your code.
However I would not change this value in your final submission (or at least, leave it at the default value, and allow the user to modify it if they wish). There are messages sent over the network at the halfway point of the lease expiration (so at 5 seconds in my setup), and if you have a lot of clients connected then this could generate a lot of unnecessary network traffic. Plus you may inadvertantly loose connections over a WAN because of network latency.
Regards, Andrew
reply
    Bookmark Topic Watch Topic
  • New Topic