Socket communication is almost completed lost does not work