общая структура
typedef struct File_Info{ // file information structure
DWORD dwFileAttributes; // DWORD dwFileAttributes file
FILETIME ftCreationTime; //
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
char strDirPath[MAX_PATH];
char strFNameORDir[MAX_PATH];
DWORD dwDir; // 0 - directory 1 - file 2 - close connection
int iCountFile;
__int64 i64TimeFile;
File_Info(): dwFileAttributes(0), nFileSizeHigh(0), nFileSizeLow(0),
dwDir(0), iCountFile(0), i64TimeFile(0)
{
::ZeroMemory(strDirPath, CELEMS(strDirPath));
::ZeroMemory(strFNameORDir, CELEMS(strFNameORDir));
};
сервер получает структуру
rv = recv (ClientSock, (char*)&lpFileInfo, sizeof (file_info), 0);
if (rv == SOCKET_ERROR)
{
switch(WSAGetLastError())
{
case(WSAECONNRESET):
LogFunc(lpdialog_info, _T("UserProcess"), _T("ECONNRESET"), _T("Connection Reset, Listening for a New Client..."));
closesocket (ClientSock);
return(0);
default: ErrorStop();
}
}
else if ( rv == 0 )
{
LogFunc(lpdialog_info, _T("UserProcess"), _T("rv = 0"), _T("Zero data \n Connection Reset, Listening for a New Client..."));
closesocket (ClientSock);
return(0);
}
} *CFILE_INFO, file_info;
клиент отправляет
if (send (ServerSock, (char*)lpFileInfo, sizeof(file_info), 0)
== SOCKET_ERROR)
{
closesocket (ServerSock);
ErrorStop();
return _T("");
}