Thread: web server coding in c

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    3

    web server coding in c

    Hi All

    I am writing a webserver which accepts HTTP/1.0 requests and sends appropriate responses. I would like to improvise to accept HTTP/1.1 requests.
    How and what should be done, any examples are appreciated .

    Thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Do you know what an RFC is?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Nevermind, devshed are on the case, nothing to see here.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    3
    Oh Come On !

    I absolutely know i am a beginner....
    I know the differences between 1.0 and 1.1

    Maybe i should frame my q differently...

    I have tried this code to set up socket reuse ,
    when i change the condition set to 0 it gives an error otherwise works fine with -1
    i am trying to set the socket option here.
    and the way i am testing is i have a html with text and image .
    so when i request it to my server its showing up as two connections rather than one, i want the .html to receive both text and image in one persistent connection.


    Code:
    if(setsockopt(newsockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) <= -1)
    {
    perror("FAIL on setsockopt, error:");
    exit(-1);
    }

    The output on server side when requesting index.html ( getting two connections for a html file(index.html) if it has a image(winter.jpg)in it)

    Code:
    bash-2.05$
    Incoming connection from <IP Address>
    Comes from the child process so child working
    GET /index.html HTTP/1.1
    GET
    /index.html
    HTTP/1.1Host: <host>:<port#>
    
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
    
    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    
    Accept-Language: en-us,en;q=0.5
    
    Accept-Encoding: gzip,deflate
    
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    
    Keep-Alive: 300
    
    Connection: keep-alive
    
    
    
    Incoming connection from <IP Address>
    Comes from the child process so child working
    GET /winter.jpg HTTP/1.1
    GET
    /winter.jpg
    HTTP/1.1Host:<host>:<port #>
    
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
    
    Accept: image/png,*/*;q=0.5
    
    Accept-Language: en-us,en;q=0.5
    
    Accept-Encoding: gzip,deflate
    
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    
    Keep-Alive: 300
    
    Connection: keep-alive
    
    Referer: http://<host>:<port#>/index.html
    Thanks for the time...

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    3
    I know

    Sorry if i have troubled you ...

    I was not sure whether it should be in network of c

    so posted on both......

    PS : These are the only two forums i have posted !


    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can i force connecting to local web server via internet network ?
    By umen242 in forum Networking/Device Communication
    Replies: 5
    Last Post: 04-29-2008, 09:21 AM
  2. Server Architecture
    By coder8137 in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-29-2008, 11:21 PM
  3. SWEBS Web Server
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 09-22-2003, 02:46 AM
  4. Web Server in Router Network...
    By Aidman in forum Tech Board
    Replies: 15
    Last Post: 01-17-2003, 10:24 PM
  5. socket question
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-19-2002, 01:54 PM