Click here to Skip to main content
15,888,984 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can i get psapi.h file Pin
benjymous5-Jan-06 0:15
benjymous5-Jan-06 0:15 
AnswerRe: How can i get psapi.h file Pin
Owner drawn5-Jan-06 0:21
Owner drawn5-Jan-06 0:21 
GeneralRe: How can i get psapi.h file Pin
vikas amin5-Jan-06 1:06
vikas amin5-Jan-06 1:06 
GeneralRe: How can i get psapi.h file Pin
Prakash Nadar5-Jan-06 1:12
Prakash Nadar5-Jan-06 1:12 
GeneralRe: How can i get psapi.h file Pin
vikas amin5-Jan-06 2:13
vikas amin5-Jan-06 2:13 
GeneralRe: How can i get psapi.h file Pin
ThatsAlok8-Jan-06 20:58
ThatsAlok8-Jan-06 20:58 
Questionplz help Pin
thes3cr3t14-Jan-06 23:16
thes3cr3t14-Jan-06 23:16 
AnswerRe: plz help Pin
David Crow5-Jan-06 3:00
David Crow5-Jan-06 3:00 
AnswerRe: plz help Pin
John R. Shaw5-Jan-06 12:34
John R. Shaw5-Jan-06 12:34 
It looks like you typed this off the top of your head, because the example would not work as is.

The do while for recieving and writing data will probably go into an infinite loop, because recieved will probably never be greater than or equal to SizeOfFile. recv may only be reading the amount of data that is currently available (per documentation), that may be less than the whole file, so you need to read it in chunks and use a seperate variable to keep track of the total amount read.

Some thing like the following should work:
int written;
int recieved_so_far = 0;
do {
recieved = recv(...);
if( recieved == 0 ) {
    // there was no data available at this time
    // you may want to go to sleep for a fraction of a second (see Sleep())
    continue; // go back to start of loop and try again.
}
else if( recieved < 0 ) {
    // whoops it is an error code (see documentation)
    // figure out how to handle it
}
recieved_so_far += recieved;
// file.write(recfileBuf,recieved);
written = file.sputn(recfileBuf,recieved);
if( written != recieved )
   // whoops! that should not have happened
} while( recieved_so_far < SizeOfFile );


Good luck!

INTP
Every thing is relative...
QuestionStop Dos box appearing on screen Pin
KevinSheedy4-Jan-06 23:02
KevinSheedy4-Jan-06 23:02 
AnswerRe: Stop Dos box appearing on screen Pin
Owner drawn4-Jan-06 23:07
Owner drawn4-Jan-06 23:07 
QuestionCDHtmlDialog (COM?): memory leak, wrong 'this' pointer, ect Pin
balage24-Jan-06 22:44
balage24-Jan-06 22:44 
QuestionI want to print using the CView Pin
vikas amin4-Jan-06 22:34
vikas amin4-Jan-06 22:34 
AnswerRe: I want to print using the CView Pin
Zdeslav Vojkovic4-Jan-06 22:52
Zdeslav Vojkovic4-Jan-06 22:52 
GeneralRe: I want to print using the CView Pin
vikas amin6-Jan-06 2:22
vikas amin6-Jan-06 2:22 
QuestionRun a Batch or .exe file from a program Pin
KevinSheedy4-Jan-06 22:10
KevinSheedy4-Jan-06 22:10 
AnswerRe: Run a Batch or .exe file from a program Pin
Owner drawn4-Jan-06 22:17
Owner drawn4-Jan-06 22:17 
AnswerRe: Run a Batch or .exe file from a program Pin
S Douglas5-Jan-06 1:05
professionalS Douglas5-Jan-06 1:05 
AnswerRe: Run a Batch or .exe file from a program Pin
ThatsAlok8-Jan-06 23:00
ThatsAlok8-Jan-06 23:00 
QuestionAccessing Windows Clock Pin
KevinSheedy4-Jan-06 22:04
KevinSheedy4-Jan-06 22:04 
AnswerRe: Accessing Windows Clock Pin
Owner drawn4-Jan-06 22:06
Owner drawn4-Jan-06 22:06 
GeneralRe: Accessing Windows Clock Pin
Anilkumar K V5-Jan-06 0:39
Anilkumar K V5-Jan-06 0:39 
AnswerRe: Accessing Windows Clock Pin
Prakash Nadar4-Jan-06 23:49
Prakash Nadar4-Jan-06 23:49 
AnswerRe: Accessing Windows Clock Pin
ThatsAlok8-Jan-06 20:55
ThatsAlok8-Jan-06 20:55 
QuestionVC++ sdi Pin
bruno9579574-Jan-06 22:03
bruno9579574-Jan-06 22:03 

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.