Rawr. The TramsmitFile API: http://msdn.microsoft.com/library/de...smitfile_2.asp
Also, just for concept, here's this extremely biased Windows C code that has printf's and WinAPI calls and other cruel nasty things that I used to do the same thing as you, transfer files, and I mean, I don't even use proper winsock2 function calls. How improper of me! Just std::cout and all the other nifty io/f stream things you want to do in substitution.
Code:
while (true)
{
if(clientSocket=accept(serverSocket, (struct sockaddr*)&clientSocketAddr, &AddrLength))
{
printf("omgclientconnected\n");
if(hFile=CreateFile("C:\\whatever.txt", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL))
{
printf("\tomgwegottohere\n");
while(true) {
BOOL bResult = ReadFile(hFile, szBuf, 1024, &dwNumRead, NULL);
if( bResult == 0 || dwNumRead == 0 )
{
break;
}
send(clientSocket, szBuf, strlen(szBuf),0);
memset(szBuf,0,1024);
printf("\troflbuffersent\n");
}
}
else printf("\tomfgfailure\n");
printf("\tomgwhatnow\n");
closesocket(clientSocket);
CloseHandle(hFile);
}
}
I don't know about better, or faster, I'm sure raw sockets would be enjoyable experience for you, but I would personally just stick to the provided winsock lib's. I don't understand what you mean by this corruption either. I mean, I guess UDP has been renowned for being "less reliable" in that packets are not guaranteed to arrive in the right order or at all, but we should just be using TCP streams here right? Maybe you want to elaborate on your problem?