Re: a server http

Discussion in 'C Programming' started by MartinBroadhurst, Mar 15, 2011.

  1. On Mar 15, 4:59 pm, "io_x" <> wrote:
    > why my little http server
    > is ok [with ms "internet explorer"] for send the right
    > file eg.  file.htm
    > but is not ok in send the file  image.gif
    > in the case that image is
    > in the page of the file.htm
    >
    > in other words, it can import the file
    > and not import the gif image in that page.
    >
    > but if i want only the image all is ok [get \image.gif http/1.1]
    > and the image is send-show ok
    >
    > there is a different header to send to the client
    > if one of two "the file.gif is stand alone file"
    > or "the file.gif is one part of the page"?
    > Thank you


    No, the headers should be the same. I would suggest that you install
    Wireshark (http://www.wireshark.org/) and have a look at the requests
    and responses. There must be a difference between the two cases.

    Incidentally, I have written a noddy HTTP server in C, which you can
    find here:

    http://www.martinbroadhurst.com/webserver.html

    Martin
     
    MartinBroadhurst, Mar 15, 2011
    #1
    1. Advertising

  2. MartinBroadhurst

    Tom St Denis Guest

    On Mar 16, 2:46 am, "io_x" <> wrote:
    > "MartinBroadhurst" <> ha scritto nel messaggio news:590298aa-4da2-4680-> there
    > is a different header to send to the client
    >
    > > if one of two "the file.gif is stand alone file"
    > > or "the file.gif is one part of the page"?
    > > Thank you

    >
    > No, the headers should be the same. I would suggest that you install
    > Wireshark (http://www.wireshark.org/) and have a look at the requests
    > and responses. There must be a difference between the two cases.
    >
    > Incidentally, I have written a noddy HTTP server in C, which you can
    > find here:
    >
    > http://www.martinbroadhurst.com/webserver.html
    >
    > Martin
    > #########
    > thank you, but i have my way


    Then why ask for help?

    Tom
     
    Tom St Denis, Mar 16, 2011
    #2
    1. Advertising

  3. Tom St Denis <> writes:

    > On Mar 16, 2:46 am, "io_x" <> wrote:
    >> "MartinBroadhurst" <> ha scritto nel messaggio news:590298aa-4da2-4680-> there
    >> is a different header to send to the client
    >>
    >> > if one of two "the file.gif is stand alone file"
    >> > or "the file.gif is one part of the page"?
    >> > Thank you

    >>
    >> No, the headers should be the same. I would suggest that you install
    >> Wireshark (http://www.wireshark.org/) and have a look at the requests
    >> and responses. There must be a difference between the two cases.
    >>
    >> Incidentally, I have written a noddy HTTP server in C, which you can
    >> find here:
    >>
    >> http://www.martinbroadhurst.com/webserver.html
    >>
    >> Martin
    >> #########
    >> thank you, but i have my way

    >
    > Then why ask for help?


    Notice that he never asked for any help: he never posted the code of his
    buggy server.

    --
    __Pascal Bourguignon__ http://www.informatimago.com/
    A bad day in () is better than a good day in {}.
     
    Pascal J. Bourguignon, Mar 16, 2011
    #3
  4. MartinBroadhurst

    Test Guest

    MartinBroadhurst <> wrote:

    >On Mar 15, 4:59 pm, "io_x" <> wrote:
    >> why my little http server
    >> is ok [with ms "internet explorer"] for send the right
    >> file eg.  file.htm
    >> but is not ok in send the file  image.gif
    >> in the case that image is
    >> in the page of the file.htm
    >>
    >> in other words, it can import the file
    >> and not import the gif image in that page.
    >>
    >> but if i want only the image all is ok [get \image.gif http/1.1]
    >> and the image is send-show ok
    >>
    >> there is a different header to send to the client
    >> if one of two "the file.gif is stand alone file"
    >> or "the file.gif is one part of the page"?
    >> Thank you

    >
    >No, the headers should be the same. I would suggest that you install
    >Wireshark (http://www.wireshark.org/) and have a look at the requests
    >and responses. There must be a difference between the two cases.
    >
    >Incidentally, I have written a noddy HTTP server in C, which you can
    >find here:
    >
    >http://www.martinbroadhurst.com/webserver.html
    >
    >Martin


    I tried the small webserver.c.
    When I go to http://127.0.0.1/ I get a file listing as expected. I changed code
    to listen to port 5700 as I have my router set to forward that to my local
    computer. http://127.0.0.1:5700/ work ok.

    However I cannot get webserver.c to answer to calls from web.
    I have a dyndns web address and router port forwarding 5700 set to my local
    computer. Need I change some code?
     
    Test, Mar 16, 2011
    #4
  5. On Mar 16, 8:03 pm, Test <test@.nil.invalid.com> wrote:

    >
    > However I cannot get webserver.c to answer to calls from web.
    > I have a dyndns web address and router port forwarding 5700 set to my local
    > computer. Need I change some code?
    >


    I can't reproduce that, but you could try changing the call to
    getaddrinfo() to pass a host name instead of NULL.

    Martin
     
    MartinBroadhurst, Mar 17, 2011
    #5
  6. MartinBroadhurst

    Tom St Denis Guest

    On Mar 28, 3:22 am, "io_x" <> wrote:
    > "io_x" <> ha scritto nel messaggionews:4d8f0d17$0$18241$...
    >
    > > Someone know what is the timeout for the server
    > > in a keep-alive connection that is silent?
    > > 10 minuts are ok?
    > > how many connection all togheter can i do? until resources ends?
    > > it seem go well 2 connection all togheter becasue browser allow
    > > only 2 it seems; but it could be more
    > > than, could be sincronizzations problems but until now no one.

    >
    > > there is a limit of the size of the file someone can send in this
    > > way?
    > > it is possbile one http server is in port 8080? and how browser
    > > can know this?
    > > one http serve can be in a port != 80
    > > all seams easy until now, i'm a little slow because write
    > > the arr library too

    >
    > the server send
    > <Header>
    > \n\n
    > <file>
    > but in the header has to be always the len of the file?
    > i think yes
    > there is a problem if the server send
    > <Header>
    > \n\n
    > the first time and then the <file>
    > or it is better to send all in one time?


    I hope you're not literally sending "<Header>" but in fact a valid
    HTTP response.

    Eitherway, this isn't the place to ask this question. Consult the RFC
    for HTTP [RFC 2616] and read up how your headers should be formatted.

    When I was in college and I wrote my own single process server [it was
    threaded...] I just looked at the headers Apache gave out and copied
    them. :)

    Once you have solid I/O routines writing a small parser/generator for
    HTTP isn't that hard, at least to get the basics going.

    Tom
     
    Tom St Denis, Mar 28, 2011
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. larkpics
    Replies:
    9
    Views:
    9,072
    Patrick.O.Ige
    Oct 22, 2005
  2. mike
    Replies:
    5
    Views:
    1,009
    Keith M. Corbett
    Sep 21, 2004
  3. -
    Replies:
    2
    Views:
    445
    Alan Krueger
    Jul 29, 2005
  4. Replies:
    3
    Views:
    841
    Guillermo
    Apr 26, 2007
  5. lkcl
    Replies:
    6
    Views:
    1,105
Loading...

Share This Page