Common code for Trillek client and server