Click here to Skip to main content
15,894,040 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow do you use combo boxes with a Doc View SDI Application Pin
D_code_writer15-Oct-06 3:10
D_code_writer15-Oct-06 3:10 
AnswerRe: How do you use combo boxes with a Doc View SDI Application Pin
cje16-Oct-06 4:37
cje16-Oct-06 4:37 
AnswerRe: How do you use combo boxes with a Doc View SDI Application Pin
Mark Salsbery16-Oct-06 7:32
Mark Salsbery16-Oct-06 7:32 
AnswerRe: How do you use combo boxes with a Doc View SDI Application Pin
D_code_writer16-Oct-06 21:54
D_code_writer16-Oct-06 21:54 
GeneralRe: How do you use combo boxes with a Doc View SDI Application Pin
Mark Salsbery17-Oct-06 6:13
Mark Salsbery17-Oct-06 6:13 
QuestionHow to use "Connection: Keep-Alive" header Pin
zzattack15-Oct-06 2:12
zzattack15-Oct-06 2:12 
AnswerRe: How to use "Connection: Keep-Alive" header Pin
Michael Dunn15-Oct-06 9:03
sitebuilderMichael Dunn15-Oct-06 9:03 
GeneralRe: How to use "Connection: Keep-Alive" header Pin
zzattack15-Oct-06 9:59
zzattack15-Oct-06 9:59 
I asked around a bit and I was told that I need to read out the Content-Length header which the server sends back. I was very proud of myself when I got that done, but then I found out that's the length of the stuff that comes after the headers, and Content-Length isn't the latest header sent Frown | :(
Anyway, I also managed to fix that up. Here's the code I used.. if anyone ever uses the search button and finds this.
void ReceiveDone(IAsyncResult^ ar) {
    Socket^ s = safe_cast<Socket^>(ar->AsyncState);
    try {
        int bytesRead = s->EndReceive(ar);
        String^ read = Encoding::ASCII->GetString(buffer, 0, bytesRead);
        sb->Append(read);
        TimesRead++;

        if (ReadingHeaders == true) {
            Int32 index = sb->ToString()->IndexOf("\r\n\r\n");

            if ((index != -1) && (ContentLength != 0)) {
                TimesRead = 0;
                sb->Remove(0, index + 4);
                ReadingHeaders = false;
            }

            else if (ContentLength == 0) {
                array<String^>^ seperators = gcnew array<String^>{"\r\n", ": "};
                // seperate sb by it's headers
                array<String^>^ headers = sb->ToString()->Split(seperators,StringSplitOptions::None);
                // quick check for Content-Length to be in buffer already
                // and also 10 characters after that
                Int32 index = sb->ToString()->IndexOf("Content-Length:");
                if ((index != -1) && (index + 10 < sb->Length)) {
                    // for loop increments 2 because only the 1st is the header name
                    for (int i = 1; i < headers->Length; i++) {
                        // found correct elements
                        if ((headers[i] == "Content-Length") && (headers[i+1]->ToString() != "")) {
                            Int32::TryParse(headers[i+1]->ToString(), ContentLength);
                            ReadsRequired = (ContentLength / buffer->Length);
                            if (ContentLength % buffer->Length > 0)
                                ReadsRequired++;
                        }
                    }
                }
            }
        }
        if ((ReadingHeaders == true) || (TimesRead < ReadsRequired))
            sock->BeginReceive(buffer, 0, buffer->Length,
                SocketFlags::None, gcnew AsyncCallback(this, &StatsSock::ReceiveDone), sock);
        else
            ParseDelegate->Invoke(sb->ToString(), this);
    }
    catch (Exception^ e) { MessageBox::Show(e->ToString()); }
}

QuestionHow to set the cursor on an EditBox? Pin
sir_moreno15-Oct-06 1:16
sir_moreno15-Oct-06 1:16 
AnswerRe: How to set the cursor on an EditBox? Pin
Mark Salsbery15-Oct-06 8:10
Mark Salsbery15-Oct-06 8:10 
Questionan existing efficient matrix multiplication algorithm? Pin
George_George15-Oct-06 1:10
George_George15-Oct-06 1:10 
QuestionLinking with Visual Studio 2003 ??? Pin
thedp15-Oct-06 0:31
thedp15-Oct-06 0:31 
AnswerRe: Linking with Visual Studio 2003 ??? Pin
Christian Graus15-Oct-06 0:48
protectorChristian Graus15-Oct-06 0:48 
GeneralRe: Linking with Visual Studio 2003 ??? Pin
thedp15-Oct-06 0:57
thedp15-Oct-06 0:57 
GeneralRe: Linking with Visual Studio 2003 ??? Pin
Christian Graus15-Oct-06 1:00
protectorChristian Graus15-Oct-06 1:00 
GeneralRe: Linking with Visual Studio 2003 ??? Pin
thedp15-Oct-06 1:04
thedp15-Oct-06 1:04 
QuestionSingleThread dialog application which can change main dialog [modified] Pin
rudo3214-Oct-06 23:11
rudo3214-Oct-06 23:11 
AnswerRe: SingleThread dialog application which can change main dialog Pin
Joan M16-Oct-06 20:52
professionalJoan M16-Oct-06 20:52 
Questionlisbox sorting Pin
Tara1414-Oct-06 19:15
Tara1414-Oct-06 19:15 
AnswerRe: lisbox sorting Pin
Joan M16-Oct-06 20:49
professionalJoan M16-Oct-06 20:49 
QuestionPrinting Bitmaps from a Frame Grabber (Re-post of earlier question) Pin
Bob Hickey14-Oct-06 16:56
Bob Hickey14-Oct-06 16:56 
AnswerRe: Printing Bitmaps from a Frame Grabber (Re-post of earlier question) Pin
Justin Tay14-Oct-06 18:45
Justin Tay14-Oct-06 18:45 
AnswerRe: Printing Bitmaps from a Frame Grabber (Re-post of earlier question) Pin
Hamid_RT14-Oct-06 19:32
Hamid_RT14-Oct-06 19:32 
Questionsort of dumb question about memory allocation Pin
KellyR14-Oct-06 14:45
KellyR14-Oct-06 14:45 
AnswerRe: sort of dumb question about memory allocation Pin
Mark Salsbery14-Oct-06 15:18
Mark Salsbery14-Oct-06 15:18 

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.