pipe to queue, client refactoring
main loop use select