This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Downloading file via Http Get


Downloading file via Http Get

Postby mehrozdurrani » Jul 22, 2010 @ 10:30am

I need help and a proper method to download a file viz httpget request i ve tried the followin code but its not helping
Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
ERESULT ClassMain::OnInit(ENATIVETYPE instance)
{

    if (ecd.net[0]->Init(ECONN_SOCKET, this) == E_OK)
        {

            ClassEConsole::MsgWindow("Socket formed");
            ecd.net[0]->SendHTTPGet("http://users.ugent.be/~bpuype/cgi-bin/fetch.pl?dl=wget/wget-1.9.1.exe");
            ClassEConsole::MsgWindow("Server formed");
            stack.Alloc(32768);
            ClassEConsole::MsgWindow("test");


        }
        else
        {
            ClassEConsole::MsgWindow("Socket not formed");
        }


    return(E_OK);
}
22 lines; 4 keywds; 3 nums; 57 ops; 5 strs; 0 coms    Syntactic Coloring v0.4 - Dan East  

Code: Select all









10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
void ClassMain::OnNetMessage(unsigned char connection, long id, long msg, long bufsize, unsigned char *buffer)
{
    EHTTPRESPONSE_INFO info;
    if (msg == ENET_SERVERFOUND)
    {
        ClassEConsole::MsgWindow("hi");
        //The client has been connected
    }

    if (msg == ENET_RECEIVEDATA)
    {
                stack.Push(buffer, bufsize);
    }

    if(msg == ENET_CLOSEDSOCKET)
    {
        /*if (stack.GetResponseInfo(&info))
        {*/

            stack.GetResponseInfo(&info);

            if(stack.BodySize() == 0)
            {
                unsigned char *bodydata = NULL;
                unsigned long bodydatasize;
                bodydata = (unsigned char *)ClassEMemory::Alloc(stack.BodySize());

                if (bodydata != NULL)
                {
                    stack.GetBody(bodydata, bodydatasize);
                    ClassEMemory::DeAlloc(bodydata);
                }
            //}
        //}
        stack.Clear();
        }
    }
}
37 lines; 19 keywds; 1 nums; 90 ops; 1 strs; 4 coms    Syntactic Coloring v0.4 - Dan East  

tell me where m doin things wrong, i need a quick help
thanks in advance
Mehroz
mehrozdurrani
pm Member
 
Posts: 1
Joined: Jul 22, 2010 @ 9:11am


Re: Downloading file via Http Get

Postby edge » Jul 28, 2010 @ 11:16am

Hi,

Are you saving the bodydata after the socket is closed? I don't see it in the sample you've posted which might explain why nothing is happening.
EDGELIB: Cross-platform mobile development at your fingertips
http://www.edgelib.com
User avatar
edge
pm Member
 
Posts: 1180
Joined: Aug 22, 2005 @ 3:42pm
Location: The Netherlands


Return to EDGELIB


Sort


Forum Description

Powerful and affordable C++ middleware solution covering true multi-platform 2D, 3D and network features for Apple iPhone, Windows Mobile, Symbian S60, UIQ, Linux and Windows desktop.

Moderator:

edge

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron