implement extern functions calls

instead of implementing the code within the thread function, declare
functions as extern, to be able to implement them outside the server
implementation