Click here to Skip to main content
16,011,711 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Is this book on the standard library worth it? Pin
Nemanja Trifunovic26-Feb-08 7:21
Nemanja Trifunovic26-Feb-08 7:21 
GeneralRe: Is this book on the standard library worth it? Pin
markt26-Feb-08 11:29
markt26-Feb-08 11:29 
GeneralRe: Is this book on the standard library worth it? Pin
User 58385226-Feb-08 15:50
User 58385226-Feb-08 15:50 
GeneralProblems receiving highspeed data using CAsyncSocket::OnReceive() Pin
97C5ENVY26-Feb-08 4:51
97C5ENVY26-Feb-08 4:51 
GeneralRe: Problems receiving highspeed data using CAsyncSocket::OnReceive() Pin
Mark Salsbery26-Feb-08 5:23
Mark Salsbery26-Feb-08 5:23 
GeneralRe: Problems receiving highspeed data using CAsyncSocket::OnReceive() Pin
97C5ENVY26-Feb-08 7:27
97C5ENVY26-Feb-08 7:27 
GeneralRe: Problems receiving highspeed data using CAsyncSocket::OnReceive() Pin
led mike26-Feb-08 7:33
led mike26-Feb-08 7:33 
GeneralRe: Problems receiving highspeed data using CAsyncSocket::OnReceive() Pin
Mark Salsbery26-Feb-08 8:12
Mark Salsbery26-Feb-08 8:12 
Always check socket error codes!

Maybe something like this (assuming all your UDP socket creation is correct/successful, buffer and
packet count variables initialized properly) ...
void CMyAsyncSocket::OnReceive(int nErrorCode)
{
    <font color="Green">// loop receiving datagrams until there's no more to receive this FD_READ cycle</font>
    while (1)
    {
        int BytesIn = ReceiveFrom(Buff, BuffSize, SenderAdd, SenderPrt);

        if (0 == BytesIn)
        {
            <font color="Green">// connection closed (TCP sockets only - should never get here with UDP)</font>
            return;
        }
        else if (SOCKET_ERROR == BytesIn)
        {
            DWORD errcode = GetLastError();
            if (WSAEWOULDBLOCK == errcode)
            {
                <font color="Green">// no more datagrams available to receive - just return</font>
                return;
            }
            else
            {
                <font color="Green">// some bad error occurred - errcode is the error code</font>
                return;
            }
        }

        <font color="Green">// Datagram successfully received!</font>
        PacketsRcvd++;

        <font color="Green">// this does nothing
        //CAsyncSocket::OnReceive(nErrorCode);</font>
    }
}
 




Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: Problems receiving highspeed data using CAsyncSocket::OnReceive() Pin
97C5ENVY26-Feb-08 8:45
97C5ENVY26-Feb-08 8:45 
GeneralRe: Problems receiving highspeed data using CAsyncSocket::OnReceive() Pin
Mark Salsbery26-Feb-08 8:50
Mark Salsbery26-Feb-08 8:50 
GeneralRe: Problems receiving highspeed data using CAsyncSocket::OnReceive() Pin
Mark Salsbery26-Feb-08 8:54
Mark Salsbery26-Feb-08 8:54 
GeneralRe: Problems receiving highspeed data using CAsyncSocket::OnReceive() Pin
ramana.g26-Feb-08 17:20
ramana.g26-Feb-08 17:20 
GeneralContext Menu item Command identification Pin
Alberto Bar-Noy26-Feb-08 4:49
Alberto Bar-Noy26-Feb-08 4:49 
QuestionRe: Context Menu item Command identification Pin
David Crow26-Feb-08 4:58
David Crow26-Feb-08 4:58 
GeneralRe: Context Menu item Command identification Pin
Alberto Bar-Noy26-Feb-08 5:12
Alberto Bar-Noy26-Feb-08 5:12 
Generalstring conversion Pin
ginjikun26-Feb-08 4:41
ginjikun26-Feb-08 4:41 
GeneralRe: string conversion Pin
David Crow26-Feb-08 4:55
David Crow26-Feb-08 4:55 
GeneralRe: string conversion Pin
CPallini26-Feb-08 5:00
mveCPallini26-Feb-08 5:00 
GeneralRe: string conversion Pin
ginjikun26-Feb-08 6:28
ginjikun26-Feb-08 6:28 
GeneralRe: string conversion Pin
CPallini26-Feb-08 8:06
mveCPallini26-Feb-08 8:06 
GeneralRe: string conversion Pin
ginjikun27-Feb-08 1:07
ginjikun27-Feb-08 1:07 
GeneralRe: string conversion Pin
CPallini27-Feb-08 2:02
mveCPallini27-Feb-08 2:02 
AnswerRe: string conversion Pin
Rajkumar R26-Feb-08 5:00
Rajkumar R26-Feb-08 5:00 
GeneralRe: string conversion Pin
ginjikun26-Feb-08 5:24
ginjikun26-Feb-08 5:24 
GeneralRe: string conversion Pin
Rajkumar R26-Feb-08 8:19
Rajkumar R26-Feb-08 8:19 

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.