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.
A message box showed up when i run my app. No errors show when compile and link.
I just want to check wether there are more data in socket to be read after "sock->Read(cBuf,sizeof(cBuf)-1);".
FireMail had a similiar error with wxSocketClient and wxSocketServer in this thread. FireMail mentions you can message him and he will provide more details.
mc2r wrote:FireMail had a similiar error with wxSocketClient and wxSocketServer in this thread. FireMail mentions you can message him and he will provide more details.
wxSockets do have flags that define how they act (blocking GUI while they receive data, receive all data at once and so on).
My problem was that i only used a single thread including GUI and sockets. You need now to imagine that without "blocking GUI"-flag the receive (or peek in your case) function calls wxYield not to block the GUI.
So you have two ways for solving that problem:
1) you stay at single thread application using blocking flag for your socket (i did not choose that method)
2) you launch the socket in a second thread (wxThread - i've chosen this method).
Ad 1) with blocking flag wxYield is not called and the GUI freezes until data arrives
Ad 2) in a second thread wxYield is called, but it does not matter because there is no GUI.
when you choose the 2nd method (second thread), be aware that you must not call GUI functions from the second thread! you need to call events because wx is not thread safe.
wxSockets do have flags that define how they act (blocking GUI while they receive data, receive all data at once and so on).
My problem was that i only used a single thread including GUI and sockets. You need now to imagine that without "blocking GUI"-flag the receive (or peek in your case) function calls wxYield not to block the GUI.
So you have two ways for solving that problem:
1) you stay at single thread application using blocking flag for your socket (i did not choose that method)
2) you launch the socket in a second thread (wxThread - i've chosen this method).
Ad 1) with blocking flag wxYield is not called and the GUI freezes until data arrives
Ad 2) in a second thread wxYield is called, but it does not matter because there is no GUI.
when you choose the 2nd method (second thread), be aware that you must not call GUI functions from the second thread! you need to call events because wx is not thread safe.
hope i could help you
Hi FireMail !
I have the same problem as you. But I use wxTCPServer and wxTCPConnection classes, which use wxSocketBase class. So the flag is wxSOCKET_WAITALL (only return when it has read or written ALL the data, but the GUI does not block). So I have tried to use threads but the problem always appears.