Page 1 of 1

Problem with socket input events

Posted: Wed Apr 01, 2009 7:58 pm
by BinaryShinigami
Hey guys. I'm creating a fairly simple IRC client to play with sockets and I'm having some problems with reading from the socket.

I know how to read and all that the problem is that it seems that the events stop being generated after the first 3 events. I have Left a pretty bare wxSOCKET_INPUT clause in my select case where is just peeks 1 byte so it should keep getting the same byte over and over to test what was going on and it only gets the 1 byte 3 times then it stops trying. I have put wxMessageBoxes at the beginning and end of the input case to see how it is executed and it seems that the event is generated and then again before the 1st pass through the function has been ended.


Code: Select all

    wxMessageBox(wxT("Input Generated"),wxT("INFO"));
The output is basically message boxes in this order:
Input Generated
Input Generated
Input Generated

Then it stops altogether can and from what I understand since I only peek'd the bytes it should keep generating the event because I have never taken it off the socket buffer.

Can someone help me with this all I want is it to keep reading and not just stop like that I have tried all of the flags for the socket like BLOCK, NOWAIT, WAITALL etc... and nothing seemed to make any difference.

Posted: Wed Apr 01, 2009 10:35 pm
by protocol
You can't expect the same/desired behavior with just any combination of flags.

Use wxSocketBase::SetFlags(wxSOCKET_WAITALL)

Also its best practice to use ::wxLogDebug(...) rather than wxMessageBox(...)