i found out what the problem was: i had to use double slashes ( \\ ).
here's the SendFile and recv code:
Code:
bool SendFile()
{
HANDLE hnd = CreateFile("D:\\aaa.txt", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hnd == INVALID_HANDLE_VALUE)
cout<<"error => "<<GetLastError()<<endl;
bool ret = TransmitFile(newConn, hnd, GetFileSize(hnd, NULL), 1, NULL, NULL, 0);
CloseHandle(hnd);
return ret;
}
Code:
char buf[2];
ZeroMemory(buf, 2);
while(true)
{
if(recv(sockfd, buf, 1, 0) > 0)
cout<<buf;
}
the problem is that everytime i get only part of the text in the file (each time different size of text).
i heard that send() sometimes doesn't send all data, but TransmitFile has the same problem?