Fixed server nullPointerException

TODO: add lenght to the written package in server

Signed-off-by: Mihaela Martinas <martinas.mihaela21@gmail.com>