Moved socket functions to extern lib