I
iwasinnihon
I writing a program that will send both a text/html document as well
as jpegs using winsock. My code works find for the text, but will not
work with jpegs. My code is below. What am I missing? Can someone
point me in the right direction.
ifstream file;
file.open(r.c_str(), ios::binary);
char buffer[1024] = "";
int BytesSent = 0;
int BytesIndex = 0;
while( !file.eof() ) {
file.read(buffer, 1024);
int BytesLeft = strlen(buffer);
while(BytesLeft != 0){
BytesSent = send(sock, &buffer[BytesIndex], BytesLeft, 0);
BytesLeft -= BytesSent;
BytesIndex +=BytesSent;
cout << buffer << endl;
}
}
as jpegs using winsock. My code works find for the text, but will not
work with jpegs. My code is below. What am I missing? Can someone
point me in the right direction.
ifstream file;
file.open(r.c_str(), ios::binary);
char buffer[1024] = "";
int BytesSent = 0;
int BytesIndex = 0;
while( !file.eof() ) {
file.read(buffer, 1024);
int BytesLeft = strlen(buffer);
while(BytesLeft != 0){
BytesSent = send(sock, &buffer[BytesIndex], BytesLeft, 0);
BytesLeft -= BytesSent;
BytesIndex +=BytesSent;
cout << buffer << endl;
}
}