Add a condition to get out of the receive loop

Now can get out of the loop when receive "\n" or "\r" or "\r\n".
Add memory allocation

Now can use strcat() correctly. It's more safe than before.
Merge pull request #21 from lzhang25/master

Add memory allocation(correct the use of strcat()).