hi, i modified code

add some helper functions for calling more straightforwardly
add some examples
add thread-safe global error string
fix bug: select function will loop endless forever because timeout always ocure immediately after first timeout return
and, format code, convert all tabs to space