Factory for client and server tcp connections