core tcp stuff (not compiling), some parts missing, to be replaced by simplier implementations