Hi Shaik,
Thanks for testing the code... I found out what is going wrong, but I didn't understand why.
When you said it worked there I tought "he must be kidding"
, because the server I wrote in SERVER_NAME parameter was right and it was in /etc/hosts file. But to make sure I was doing the right think, I added a line in the code to print the servername before calling rexec and then for my surprise I discovered what was happening.
In the first time the server was right, the one in SERVER_NAME constant, the second time the server was diferent, it was another alias name for the same IP in the /etc/hosts, but at the third time and from there on, the servername was an alias for a different IP, so that's why it never connected again, even after I changed the password.
But I didn't understand why it is getting this servername for another IP address.
Here is a piece of my /etc/hosts.
xxx.xxx.0.1 localhost
xxx.xxx.2.20 vicunha1
xxx.xxx.72.21 sscxwin1
xxx.xxx.72.22 sscsp02
xxx.xxx.72.9 sscsp11
xxx.xxx.2.24 bscs
xxx.xxx.16.34 uatr1dfr
xxx.xxx.2.56 sdrdig14
xxx.xxx.2.56 vicunha14
xxx.xxx.72.25 sscsp05.ac.com sscsp05 #System name
xxx.xxx.72.92 AC7932CY570122
I was trying to connnect to the server "sscsp05", so at the first time it pszInitiatorIpAddress was pointing to this string, the second time it has "sscsp05.ac.com" and at a third time it has "sscxwin1", a different IP address.
I tested it trying to connect to server "sscsp02", and the same thing happened, but at the second time it already got "sscsxwin1".
So, to solve this, everytime I set pszInitiatorIpAddress to point to szInititatorIpAddress again. I also tested using 10 threads, and all of them connected successfully.
Do you have any idea why rexec is getting other server names in /etc/hosts?? I looked at the man page and it doesn't say anything about getting other servernames dinamically.
Thank you.