i have 2 questions about TransmitFile:
1) when i write 1 for the nNumberOfBytesPerSend argument, it should send the file byte by byte right? so why it doesn't send him this way? it sends the first 2 bytes in the first transmit, and all the rest in the second one.
2) i want to send some data before and after the file, so i'm using the lpTransmitBuffers parameter:
but it only sends the Head buffer and stops, it doesn't even send the file itself.
char buff = "start";
char buffb = "end";
tfb.Head = buff;
tfb.HeadLength = sizeof(buff);
tfb.Tail = buffb;
tfb.TailLength = sizeof(buffb);
>> 1) when i write 1 for the nNumberOfBytesPerSend argument, it should send the file byte by byte right? so why it doesn't send him this way? it sends the first 2 bytes in the first transmit, and all the rest in the second one. <<
How do you know this? It may be calling send byte by byte but these are being combined into bigger transmits at a lower level. Alternatively the receiving computer may be combining multiple packets of received data into a bigger recv call. You can not expect a one to one relationship between send and recv with the TCP protocol.
>> but it only sends the Head buffer and stops, it doesn't even send the file itself. <<
Could you post your code? One thing I can think of is that you are transmitting a nul character at the end of the word "start". This means if you print out the received buffer it will stop at the first nul character and not print the file contents.
i gave the code...
i changed the size from sizeof(buff) to 5 and it works now. but it prints the head buffer, the file and the tail buffer in one messagebox (the messagebox jumps with the data when a message received). i think it's because what u said before about the bytes being combined, but how can i seperate the head data from the file contents?
It is your responsibility to split up the data. One way you can do this is to transmit the length of each part of the data before the data. For example, you could transmit "5start100FileContents...3end" and then use the numbers to split up the data. Another way is to seperate the data using a special character. For example if you sperated the data with a nul character you could get each part with the following code:
char* start = buf;
char* file = start + strlen(start) + 1;
char* end = file + strlen(file) + 1;