Click here to Skip to main content
15,885,025 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Curious Pin
Gwenio19-Apr-10 13:13
Gwenio19-Apr-10 13:13 
GeneralRe: Curious Pin
Richard MacCutchan20-Apr-10 1:16
mveRichard MacCutchan20-Apr-10 1:16 
GeneralRe: Curious Pin
Stephen Hewitt19-Apr-10 13:54
Stephen Hewitt19-Apr-10 13:54 
GeneralRe: Curious Pin
Gwenio19-Apr-10 14:02
Gwenio19-Apr-10 14:02 
Questionwchar_t / C++ Pin
Fareed Rizkalla18-Apr-10 9:19
Fareed Rizkalla18-Apr-10 9:19 
AnswerRe: wchar_t / C++ Pin
Chris Losinger18-Apr-10 9:51
professionalChris Losinger18-Apr-10 9:51 
AnswerRe: wchar_t / C++ Pin
Richard MacCutchan18-Apr-10 11:09
mveRichard MacCutchan18-Apr-10 11:09 
QuestionWinSock 2 / Win32 Pin
Fareed Rizkalla18-Apr-10 9:15
Fareed Rizkalla18-Apr-10 9:15 
This is a function receiving a CDownload class structure.

WSADATA WS2Info;
if (!WSAStartup(MAKEWORD(2,2), &WS2Info))
{
    MessageBox(g_hWindow, L"WinSock2 Initialized", L"Tracing", NULL);

    // IPv4
    SOCKET IPv4 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (IPv4 != INVALID_SOCKET)
    {
        hostent *ResolveHost;
        char *HostName = new char[wcslen(Download->HostName)];
        wctomb( HostName, (wchar_t)Download->HostName);
        ResolveHost = gethostbyname(HostName);

        MessageBox(g_hWindow, L"Resolving Host", L"Tracing", NULL);

        if (ResolveHost)
        {
            MessageBox(g_hWindow, L"Connecting", L"Tracing", NULL);
            SOCKADDR_IN Host;
            Host.sin_family = AF_INET;
            Host.sin_addr.s_addr = (ULONG)ResolveHost->h_addr_list[0];
            if (Download->ConnectionProtocol == Download->HTTP)
                Host.sin_port = htons(80);

            if (!connect(IPv4, (SOCKADDR*) &Host, sizeof(Host)))
            {
                MessageBox(g_hWindow, L"Connected", L"Tracing", NULL);

                char *HostFileLocation = new char[wcslen(Download->HostFileLocation)];
                wctomb(HostFileLocation, (wchar_t)Download->HostFileLocation);
                char TCPsend[DEFAULT_BUFLEN];
                sprintf(TCPsend,"GET %s\r\n\r\n",HostFileLocation);
                send(IPv4,TCPsend,strlen(TCPsend),0);

                TotalBytesToDownload += Download->BytesToDownload;
                TotalBytesDownloaded += Download->BytesDownloaded;

                ofstream DownloadFile ( Download->FileName, std::ios::out );

                int ReceivedBytes = 0;
                char TCPrecv[DEFAULT_BUFLEN];
                do
                {

                    MessageBox(g_hWindow, L"Downloading", L"Tracing", NULL);

                    ReceivedBytes = recv(IPv4, TCPrecv, DEFAULT_BUFLEN, 0);

                    TotalBytesDownloaded += ReceivedBytes;
                    Download->BytesDownloaded += ReceivedBytes;

                    DownloadFile << TCPrecv;
                }
                while (ReceivedBytes && Download->DownloadState == Download->ACTIVE);

                DownloadFile.close();

                MessageBox(g_hWindow, L"Download Finished", L"Tracing", NULL);

                closesocket(IPv4);
            }
        }
    }
}
WSACleanup();


Some files are not 0kb in size, but appear to be corrupted and some files appear to have 0kb in size.
It's more file extension related.

I started thinking if it might be a Windows Firewall related problem, but if it connects I think everything is ok with the Windows Firewall. Or if Windows Firewall abrupt's connection pathway during recv, well need an opinion. Confused | :confused:

Thanks in advance.
AnswerRe: WinSock 2 / Win32 Pin
Richard Andrew x6418-Apr-10 13:33
professionalRichard Andrew x6418-Apr-10 13:33 
AnswerRe: WinSock 2 / Win32 [modified] Pin
Moak18-Apr-10 20:21
Moak18-Apr-10 20:21 
GeneralRe: WinSock 2 / Win32 Pin
Fareed Rizkalla19-Apr-10 3:10
Fareed Rizkalla19-Apr-10 3:10 
GeneralRe: WinSock 2 / Win32 Pin
Moak19-Apr-10 4:09
Moak19-Apr-10 4:09 
GeneralRe: WinSock 2 / Win32 Pin
Spawn@Melmac19-Apr-10 4:27
Spawn@Melmac19-Apr-10 4:27 
GeneralRe: WinSock 2 / Win32 Pin
Fareed Rizkalla4-May-10 21:02
Fareed Rizkalla4-May-10 21:02 
GeneralRe: WinSock 2 / Win32 Pin
Spawn@Melmac5-May-10 0:13
Spawn@Melmac5-May-10 0:13 
Questionprevious next button to change pictures Pin
taouki18-Apr-10 7:04
taouki18-Apr-10 7:04 
AnswerRe: previous next button to change pictures Pin
cconklin18-Apr-10 7:07
cconklin18-Apr-10 7:07 
GeneralRe: previous next button to change pictures Pin
taouki18-Apr-10 7:10
taouki18-Apr-10 7:10 
AnswerRe: previous next button to change pictures Pin
loyal ginger18-Apr-10 7:41
loyal ginger18-Apr-10 7:41 
GeneralRe: previous next button to change pictures Pin
taouki18-Apr-10 7:54
taouki18-Apr-10 7:54 
GeneralRe: previous next button to change pictures Pin
loyal ginger18-Apr-10 9:03
loyal ginger18-Apr-10 9:03 
AnswerRe: previous next button to change pictures Pin
Maximilien18-Apr-10 8:01
Maximilien18-Apr-10 8:01 
QuestionRe: previous next button to change pictures Pin
David Crow19-Apr-10 3:30
David Crow19-Apr-10 3:30 
AnswerRe: previous next button to change pictures Pin
taouki23-Apr-10 23:50
taouki23-Apr-10 23:50 
QuestionClicking a windowless button programatically Pin
Green Fuze18-Apr-10 5:19
Green Fuze18-Apr-10 5:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.