I have posted this on different forums and here, I KNOW what is the issue ( no need to repeat that here) , but I really do not have a solution.
I am using cout to track code process, works fine.
I am using perror to identify code erros - where applicable.
Even when perror returns "Invalid argument" it helps with debugging.
perror / cerr DO NOT follow the code flow.
According to responses I have received both cout and perror/cerr are BUFFERED , but perror/cerr actual outputs to console (terminal) is NEVER put in same "place" , but mostly at the end of the code run.
perror/cerr are output in red - that helps , but I really would like to have them in correct code sequence.
I DO NOT KNOW HOW TO buffer/ unbuffer perror/ cerr so it does output in correct code sequence.
I have been putting off the solution for long time, now I am open to suggestions HOW to fix this,
Attached code and output demonstrate the issue.
<pre> if (FileDescriptor_socket) {
cout << "Synchronize @line " << __LINE__ << endl;
perror("socket allocated SUCCESS");
cerr << "socket allocated SUCCESS" << endl;
cout << "Synchronize @line " << __LINE__ << endl;
return 0;
STOP @line 1437
Synchronize @line 1445
I like to see perror/cerr here
Synchronize @line 1448
STOP @line 744
SUCCESS SERVER.AllocateSocket()
function Socket_RX_Composite
STOP @line 749
TASK @line 753
function Socket_RX_Composite
STOP @line 755
Not here
socket allocated SUCCESS: Success
socket allocated SUCCESS
What I have tried:
Posted in efferent forums, this is just 30 characters fill as required.