Fix some problems with tcp socket recv