If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
I have wxSocketClient created with default parameters in Ctor and at wxSOCKET_INPUT I read all the data and it works fine. The problem is, it does not exit the loop and so I never get message "LOOP DONE", Here is the code that does the reading. I expected it to exit on error or when it could not read data anymore but it is not the case. Any light on this is appreciated!
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
//flags for notify in case they are necessary
SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG | wxSOCKET_CONNECTION_FLAG);
That is all I have set.
iwbnwif wrote: ↑Fri Jun 07, 2019 10:00 am
Also, out of interest, why are you subclassing wxSocketClient? I think this isn't necessary for a simple transfer.
Aha!, I was experimenting with many stuffs. Definitely in the real app, it won't be so. wxSocketClient will be just a member of the class not subclassed
Looking at it, it does the same thing only different positioning. Yours check immediately after reading, mine checks before next iteration of while loop. I don't think the condition is the issue. No?
Chief Justice: We have trouble dear citizens! Citizens: What it is his honor? Chief Justice:Our president is an atheist, who will he swear to?
For Read() not to wait for data and for LastReadCount() to return 0.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
I know very little about sockets, but isn't a socket connection like a phone call? You don't know when the conversation is finished until one of the partners "hangs up" or if they agreed on some method to indicate it's finished? (Like saying "bye").
In the sockets sample the first byte of the message is the length of the message, so that the receiver knows when it's complete.
doublemax wrote: ↑Fri Jun 07, 2019 10:55 am
I know very little about sockets, but isn't a socket connection like a phone call? You don't know when the conversation is finished until one of the partners "hangs up" or if they agreed on some method to indicate it's finished? (Like saying "bye").
In the sockets sample the first byte of the message is the length of the message, so that the receiver knows when it's complete.
Looking at it, it does the same thing only different positioning. Yours check immediately after reading, mine checks before next iteration of while loop. I don't think the condition is the issue. No?
It really can be checked easily
So in your case loop will works while this condition is true:
and it will be false only when both condition will false. And I really don't know when Error/0 will return true. So you can even not check LastReadCount/0 at all because this part will evaluating only when first is false.
adding the flag causes it read only once and never hit the end of the loop. So the problem is even bigger now
Check the program flow mentioned by Kvaz1r. I think that you need both the flag and to adjust the 'if' condition.
I know very little about sockets, but isn't a socket connection like a phone call? You don't know when the conversation is finished until one of the partners "hangs up" or if they agreed on some method to indicate it's finished? (Like saying "bye").
I also don't know much about sockets, but I think it is possible to use wxSOCKET_NOWAIT to put the speakerphone on and do something else whilst waiting for the other party to talk (or say something interesting)
In the sockets sample the first byte of the message is the length of the message, so that the receiver knows when it's complete.
The sample is a little outdated, we now have WriteMsg() and ReadMsg() to do the same thing. These shouldn't be used with wxSOCKET_NOWAIT though.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
iwbnwif wrote: ↑Fri Jun 07, 2019 11:26 am
Check the program flow mentioned by Kvaz1r. I think that you need both the flag and to adjust the 'if' condition.
It does not change the situation at all, after all adjustment
iwbnwif wrote: ↑Fri Jun 07, 2019 11:26 am
I also don't know much about sockets, but I think it is possible to use wxSOCKET_NOWAIT to put the speakerphone on and do something else whilst waiting for the other party to talk (or say something interesting)
Sockets seems to be least known subject to many and am not an exception
In the sockets sample the first byte of the message is the length of the message, so that the receiver knows when it's complete.
The sample is a little outdated, we now have WriteMsg() and ReadMsg() to do the same thing. These shouldn't be used with wxSOCKET_NOWAIT though.
[/quote]
I will try them out later to see if there is any difference at all!
Chief Justice: We have trouble dear citizens! Citizens: What it is his honor? Chief Justice:Our president is an atheist, who will he swear to?