Update main.cpp

non blocking read/write with callback functions