fix socket outputstream bug, and optimize server base socket code