-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made example more comprehensive #9
Conversation
@@ -61,8 +60,7 @@ static void* wh_ClientTask(void* cf) | |||
ret = wh_Client_EchoRequest(client, | |||
tx_req_len, tx_req); | |||
if( ret != WH_ERROR_NOTREADY) { | |||
printf("Client EchoRequest:%d, len:%d, %s\n", | |||
ret, tx_req_len, tx_req); | |||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should just remove this if statement if it no longer does anything, no point in keeping it around. Though it would be helpful to keep a printout that displays the error code that caused the failure. Why did you want to remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it to just clean up the output, I can re add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or would you rather I get rid of the statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that output would only be shown if there was a real error, so I'd keep it in. Maybe just make the printout more clear, since I think tx_req
and tx_req_len
wouldn't be populated on error anyway. Something like printf("wh_Client_EchoRequest failed with ret=%d\n", ret);
if(ret != WH_ERROR_NOTREADY) { | ||
if (!connectionMessage) { | ||
printf("Successful connection!\n"); | ||
connectionMessage = 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is wrong, it prints Successful connection when the client fails to connect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought != WH_ERROR_NOTREADY
meant it was a pass, before I changed the contents of that case what ever is in it prints out. If that case is a fail then it seems the example has more issues than originally thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the example is correct as it was written (at least this part of it), your assumption about how it works is incorrect. ret != WH_ERROR_NOTREADY
doesn't mean it is a pass, the function could very well return a fatal error here. But if it returns 0
then it is success. Note the conditions of the do while
loop. The original example printed the return value and the contents of the buffer on success AND if there was an error code != WH_ERROR_NOTREADY
just for debugging purposes. You just changed that to say "success", when in reality a fatal error code could have been returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, I will fix this. Thank you for the clarification!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I addressed the case appropriately now.
removed unused variable
Just added some better print outs for connections between server and client.