add buffer and period settings, improve tcp connection