rewrite to use sockets instead of tcpclient.
Added errormessage handling
added loggin class