disconnection and server startup

10 views
Skip to first unread message

Cihat

unread,
Oct 29, 2009, 12:35:04 AM10/29/09
to rpyc
Hi,

When a client makes a connection to the service-based threaded server,
the on_connect method on the service object is triggered, similarly
the on_disconnect method is invoked when the client disconnects. How
does the server know that, the client is dead? Does the server poll
the client in the background or expect the client to notify him before
it dies? If it is the second case, Is there a possibility (maybe
machine failure) that the client doesn't get a chance to notify the
server right before it dies? Can we assume that the on_disconnect will
always be triggered whenever the client dies?

The other query I have, Is there a way to do some initialization code
right after starting the threaded server? Because, the moment you
start the server, it goes into infinite loop, you lose control of the
execution.

Thanks,
Cihat

tomer filiba

unread,
Nov 3, 2009, 9:45:18 AM11/3/09
to rp...@googlegroups.com
the on_disconnect is called when the connection is closed. the server and the client don't communicate with each other,
except for the normal flow of TCP -- when one side closes the writing (sends FIN), the other side recv() an empty buffer,
which tells it the stream has ended, so rpyc closes it, and the finalization code is invoked.

why do you want to *start* the server and then do initialization?
for pathological cases, you can derive a new class from it, say

class MyThreadedServer(ThreadedServer):
   ...

and place initialization code in __init__. but why? today, the code for creating a server looks like so:

s = ThreadedServer(....parameters....)
s.start()

so either you place your code between the two lines, or invoke s.start() on a thread.
but since we're talking about a *server*, does it not make sense for it block?

btw, you can always call s.close() (also invoked by SIGINT) to terminate the server cleanly.


hope this helps,
-tomer


An NCO and a Gentleman
Reply all
Reply to author
Forward
0 new messages