Communication problem with C++

I finally made a combination of all your suggestions and it's working. Thank you very much to everyone!
Cheers!