added parser and protocol, rewrote socket handling