Server functionality added

provisional solved threadproblem with loop