Click here to Skip to main content
15,908,455 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Win32 Menu bitmaps Pin
Richard MacCutchan18-Aug-13 1:25
mveRichard MacCutchan18-Aug-13 1:25 
GeneralRe: Win32 Menu bitmaps Pin
Jonathan Davies18-Aug-13 5:20
Jonathan Davies18-Aug-13 5:20 
AnswerRe: Win32 Menu bitmaps Pin
pasztorpisti18-Aug-13 4:36
pasztorpisti18-Aug-13 4:36 
GeneralRe: Win32 Menu bitmaps Pin
Jonathan Davies18-Aug-13 5:05
Jonathan Davies18-Aug-13 5:05 
GeneralRe: Win32 Menu bitmaps Pin
pasztorpisti18-Aug-13 5:27
pasztorpisti18-Aug-13 5:27 
GeneralRe: Win32 Menu bitmaps Pin
Jonathan Davies18-Aug-13 5:40
Jonathan Davies18-Aug-13 5:40 
GeneralRe: Win32 Menu bitmaps Pin
pasztorpisti18-Aug-13 5:43
pasztorpisti18-Aug-13 5:43 
QuestionUDP sockets - not getting FD_READ after some time of activity on a socket Pin
csrss17-Aug-13 6:28
csrss17-Aug-13 6:28 
Hi there everyone.
I have some pretty much basic UDP sockets scenario: my app requests data from server and receives requested data. There is a lot of data so there is a cancellation method as well. When I cancel data receiving and request data again, app not getting FD_READ events anymore. Strange thing is, it is not always the same - sometimes there are a couple of FD_READs, sometimes half of the data could be transmitted before it stops, sometimes - none.
Code itself is basically the same as anywhere on the net and goes like this:

1. Before any receiving, check if FD_READ is set
C++
DWORD dwResult = 
::WSAWaitForMultipleEvents(vecHandles.size(), &vecHandles[0], FALSE, dwTimeout, FALSE);


- vecHandles is a vector of event handles, which includes my WSAEVENT for triggering cancellation.
which is done like this:
C++
::WSASetEvent(hEvent);

So now ::WSAWaitForMultipleEvents will return with my event.

2. Check which event we got: if it is read event, then call recv.
C++
if( socket_event_read * pReadEvent = dynamic_cast<socket_event_read *>(pSocketEvent) )
{
    WSANETWORKEVENTS nt = { 0x00 };
    if( SOCKET_ERROR != ::WSAEnumNetworkEvents(pReadEvent->get_socket(), pSocketEvent, &nt) )
    {
        if( nt.lNetworkEvents & FD_READ && nt.iErrorCode[FD_READ_BIT] == false )
        {
            ::WSARecvFrom(...);
        }
    }
}


3. Handle data.
That's it. It all works great if receiving is never cancelled. Otherwise it just stops at some point while waiting for multiple events (::WSAWaitForMultipleEvents) Again, what I mean is:
I hit cancel button and
C++
::WSASetEvent(hEvent);
is called, that causes ::WSAWaitForMultipleEvents to return with my cancel event (WSAWaitForMultipleEvents is called in a loop for every incoming data chunk - each one is about 512kb). And then app just stops receiving - it leaves socket as it is, socket is not closed and still alive. Then I hit a button again for app to begin download data again and that is when app stops receiving packets because WSAWaitForMultipleEvents is waiting for fd_read which is never signaled. Then I hit cancel again, - this is handled properly and then again download data - this time data is downloading ok.
This behavior occurs all the time.

I am struggling with this for a couple of days now and got completely no idea what is going on, have searched all the net with no result. I have tried checking, when cancellation is issued, if there is still any data pending on the socket and reading this data - all in vain - it is still remains stuck and not getting fd_read event Frown | :(

Maybe this issue is related to the fact that app is using one single socket all the time? Maybe it is because server fails and stops sending data? (I have to investigate server as well)
Maybe there is something that you may know and be able to help me with this?

Thanks in advance.
011011010110000101100011011010000110100101101110
0110010101110011

SuggestionRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
pasztorpisti17-Aug-13 7:01
pasztorpisti17-Aug-13 7:01 
GeneralRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
csrss17-Aug-13 7:45
csrss17-Aug-13 7:45 
GeneralRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
pasztorpisti17-Aug-13 8:16
pasztorpisti17-Aug-13 8:16 
GeneralRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
csrss17-Aug-13 8:48
csrss17-Aug-13 8:48 
GeneralRe: UDP sockets - not getting FD_READ after some time of activity on a socket Pin
pasztorpisti17-Aug-13 8:53
pasztorpisti17-Aug-13 8:53 
QuestionDirectX hierarchy - who is on first? Pin
Vaclav_17-Aug-13 3:07
Vaclav_17-Aug-13 3:07 
AnswerRe: DirectX hierarchy - who is on first? Pin
Richard MacCutchan17-Aug-13 5:45
mveRichard MacCutchan17-Aug-13 5:45 
AnswerRe: DirectX hierarchy - who is on first? SOLVED Pin
Vaclav_17-Aug-13 18:12
Vaclav_17-Aug-13 18:12 
Questionerror -1.#IND00 in vc++2010 Pin
yahya7716-Aug-13 5:40
yahya7716-Aug-13 5:40 
AnswerRe: error -1.#IND00 in vc++2010 Pin
Chris Losinger16-Aug-13 5:55
professionalChris Losinger16-Aug-13 5:55 
AnswerRe: error -1.#IND00 in vc++2010 Pin
Thong LeTrung16-Aug-13 6:22
Thong LeTrung16-Aug-13 6:22 
AnswerRe: error -1.#IND00 in vc++2010 Pin
Thong LeTrung16-Aug-13 6:40
Thong LeTrung16-Aug-13 6:40 
GeneralRe: error -1.#IND00 in vc++2010 Pin
yahya7716-Aug-13 7:07
yahya7716-Aug-13 7:07 
AnswerRe: error -1.#IND00 in vc++2010 Pin
Thong LeTrung16-Aug-13 7:04
Thong LeTrung16-Aug-13 7:04 
GeneralRe: error -1.#IND00 in vc++2010 Pin
yahya7716-Aug-13 7:17
yahya7716-Aug-13 7:17 
QuestionHow To Save Data for Microsoft Word 2007 or 2010 on Windows OS Pin
Thong LeTrung15-Aug-13 23:07
Thong LeTrung15-Aug-13 23:07 
AnswerRe: How To Save Data for Microsoft Word 2007 or 2010 on Windows OS Pin
Erudite_Eric15-Aug-13 23:13
Erudite_Eric15-Aug-13 23:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.