move tcp func's to extern lib