Added newthread for listener. Perform listen in separate thread and send data in main thread. Switch to named pipes for inter thread communication.