Fix bug of keep alive logic while transfering file.
Fix bug of writing file function. Adjust message buffer size.
Fix bug of exception handling. Resize socket receive buffer.