rb code for both client & server