Click here to Skip to main content
15,868,016 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Please give me some suggestion! Pin
Owner drawn4-Jan-06 20:15
Owner drawn4-Jan-06 20:15 
GeneralRe: Please give me some suggestion! Pin
LaHaHa4-Jan-06 21:21
LaHaHa4-Jan-06 21:21 
GeneralRe: Please give me some suggestion! Pin
vikas amin4-Jan-06 20:08
vikas amin4-Jan-06 20:08 
AnswerRe: Please give me some suggestion! Pin
Cool Ju4-Jan-06 22:08
Cool Ju4-Jan-06 22:08 
GeneralRe: Please give me some suggestion! Pin
LaHaHa4-Jan-06 23:33
LaHaHa4-Jan-06 23:33 
GeneralRe: Please give me some suggestion! Pin
Cool Ju4-Jan-06 23:45
Cool Ju4-Jan-06 23:45 
GeneralRe: Please give me some suggestion! Pin
LaHaHa5-Jan-06 14:28
LaHaHa5-Jan-06 14:28 
QuestionFile Transfer Client/Server (Proof Read) Pin
thes3cr3t14-Jan-06 12:32
thes3cr3t14-Jan-06 12:32 
Hi there, Iv wrote a program to transfer files between a cleint and a server,the code works fine for small files but not for large files,im going to post the code wich i hope will help other people trying to do something similar and in hope that i can get some suggestions on how to improve the code iv wrote.

<server>
{
char *buffer;
char sizebuf[20] = "";
long SizeOfFile = 1;
long BytesSent = 0;

std::ifstream file ("C:\\Windows\\Example.exe" std::ios::in | std::ios::binary | std::ios::ate);
if (!file)
{
MessageBox(NULL,"Error Opening File",NULL,MB_OK);
}
SizeOfFile = file.tellg(); //get size of file
file.seekg (0, std::ios::beg);
ltoa(SizeOfFile,sizebuf,10); //put sizeoffile in char buf
send(newsock,sizebuf,strlen(sizebuf),0);//send the size to client
buffer = new char[SizeOfFile];
file.read (buffer,SizeOfFile).eof();
do{
BytesSent = send(newsock,buffer,SizeOfFile,0);
}while(BytesSent < SizeOfFile);


Here i dont know if i should be reading blocks of the file into the buffer in the do while loop or out side of the loop and i dont know how to equally divide the file into "Chunks" to be sent separatly and rebuilt the other side help would be appriciated Smile | :)


<client><mfc>
{
char buffer[20];
long SizeOfFile = 0;
char* recvfilebuf;

recv(Socket,buffer,sizeof(buffer),0); //recv size of file to be d/l
SizeOfFile = atol(buffer);
ZeroMemory(buffer,20);

recvfileBuf = new char[SizeOfFile];
std::fstream file (C:\\Example.exe, std::ios::out | std::ios::binary | std::ios::ate); //Dir of our new .exe
if (!file)
{
MessageBox(NULL,"Error Opening File",MB_OK);
}

do
{
recieved = recv(Socket,recvfileBuf,SizeOfFile,0); //recv actuall file
file.write(recvfileBuf,recieved).eof(); //write new file

}while(recieved < SizeOfFile);
ZeroMemory(buffer,20);
}

I know there is a better way of doing what im trying to do but its hard without extensive know how on the subject..Any comments would be greatly apriciated Smile | :)

Thankyou
AnswerRe: File Transfer Client/Server (Proof Read) Pin
sunit54-Jan-06 20:06
sunit54-Jan-06 20:06 
Questionresize Frame Pin
LeeeNN4-Jan-06 11:50
LeeeNN4-Jan-06 11:50 
AnswerRe: resize Frame Pin
Christian Graus4-Jan-06 12:31
protectorChristian Graus4-Jan-06 12:31 
AnswerRe: resize Frame Pin
vikas amin4-Jan-06 20:07
vikas amin4-Jan-06 20:07 
QuestionManaging Threads in VC++ Pin
pavanbabut4-Jan-06 10:43
pavanbabut4-Jan-06 10:43 
AnswerRe: Managing Threads in VC++ Pin
Blake Miller4-Jan-06 11:44
Blake Miller4-Jan-06 11:44 
GeneralRe: Managing Threads in VC++ Pin
pavanbabut4-Jan-06 12:04
pavanbabut4-Jan-06 12:04 
GeneralRe: Managing Threads in VC++ Pin
Blake Miller4-Jan-06 12:23
Blake Miller4-Jan-06 12:23 
GeneralRe: Managing Threads in VC++ Pin
vikas amin4-Jan-06 18:21
vikas amin4-Jan-06 18:21 
QuestionProblem with SetBkColor Pin
KellyR4-Jan-06 10:00
KellyR4-Jan-06 10:00 
AnswerRe: Problem with SetBkColor Pin
Office Lineman4-Jan-06 10:09
Office Lineman4-Jan-06 10:09 
GeneralRe: Problem with SetBkColor Pin
KellyR4-Jan-06 10:20
KellyR4-Jan-06 10:20 
GeneralRe: Problem with SetBkColor Pin
Office Lineman4-Jan-06 10:36
Office Lineman4-Jan-06 10:36 
QuestionTEXT FILE? Pin
pvatanpour4-Jan-06 9:08
pvatanpour4-Jan-06 9:08 
AnswerRe: TEXT FILE? Pin
Wes Aday4-Jan-06 9:35
professionalWes Aday4-Jan-06 9:35 
AnswerRe: TEXT FILE? Pin
David Crow4-Jan-06 9:42
David Crow4-Jan-06 9:42 
GeneralRe: TEXT FILE? Pin
Nish Nishant4-Jan-06 9:51
sitebuilderNish Nishant4-Jan-06 9:51 

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.