refactor the client side

also add NULL return check!
add header file and compile to lib.a
update test.c to write a message
some Readme update about server error