Thread: Web Servers

  1. #1
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949

    Web Servers

    Is there any place I can view the source of a web server created in C or C++? Thanks !
    Do not make direct eye contact with me.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    APACHE!
    Away.

  3. #3
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Forgot to add this: also, a tutorial on making them? PS Thanks confuted .
    Do not make direct eye contact with me.

  4. #4
    Wen Resu
    Join Date
    May 2003
    Posts
    219
    For a tutorial, try google.
    you'll need to know HTTP protocols, to know what requests you'll be getting <like GET, POST etc etc etc> could be a very fun learn experience have fun.

  5. #5
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Try my site at http://swebs.sourceforge.net

    Thats a web server I'm working on now. Its only 1900 or so lines, and most of the stuff you need to know is in the connection.hpp file. Its very simple and is fully HTTP/1.1 compliant.

    Also, search google for "http made easy", its a page I used that has a lot of information about how HTTP works, and what a web server must do to be HTTP compliant.

  6. #6
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    I'm guessing you mean this? Thanks for the link / code. I'll look into both, thanks again .
    Do not make direct eye contact with me.

  7. #7
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Yep thats the one, its the greatest thing ever written on the subject IMHO. I'm sorry about the code on my site, at the moment you have to download the entire installer to view the code, so I'm going to upload all the source now seperately. Check it sometime today (the sourceforge servers are down at the moment).

  8. #8
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    In your code, stovellp, it looks like you don't wait for the new thread to finish processing the request before you delete the thread (main.cpp:387)... couldn't that be a problem if you had, say, a very large request which took a few seconds to send?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  9. #9
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Thanks for looking X-Squared, my understanding of threads with NT is not very solid.

    Code:
    hThread = CreateThread( 
    NULL,
    0,
    ProcessRequest,
    &Argument,
    0,
    &dwThreadId);
    
    if (hThread != NULL)
    {
        CloseHandle( hThread );
    }
    To my understanding, that creates a thread and tells it to run the function ProcessRequest(), which does the request. Then when thats finished, it moves on to close the handle to the thread... doesn't it?

    Actually... now that I think about it, perhaps not. Maybe your right! What should I do in regards to closing the thread then to ensure it is closed properly AFTER the request is handled? Also, there must be a way for there to be more than one instance of this thread running (because its created for every new request).

    Edit: Although, I just finished sending a file to someone that was over 600k with the server (over dial up too), which took a minute or so, and arrived perfectly in tact. So I don't think theres any problems with the threads.
    Last edited by nickname_changed; 08-23-2003 at 11:52 PM.

  10. #10
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    I'm not sure how threading works, actually, I just am not sure what exactly CreateThread and CloseThread do.

    [edit]
    According to MSDN, CloseThread( ) doesn't actually terminate the thread, and CreateThread( ) doesn't wait for the thread to finish before returning. So, it looks like what you're doing is actually fine.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  11. #11
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Ahh excellent. I knew that before I wrote the code actually, I was just testing (read: I guess I lucked out on that one, phew). Can you see any other problems in that code XSquared? I like having someone with your skills look over a project like this for me

  12. #12
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >> I like having someone with your skills look over a project like this for me.
    LOL. I'm still in high school, and I've never taken any courses (or bought any books about) C/C++ (although I have won an Ontario-wide programming contest). If you want someone with real skills, look to Prelude or Salem.

    But thanks for the compliment.

    I'm heading to bed now, but I'll have a look at the rest of the code tomorrow.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  13. #13
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    > http://swebs.soureforge.net - My web server that I'm working on.

    Its sourceforge, not soureforge. Nice looking site. I'll download it later.

  14. #14
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    lol, ops, I'd never noticed that I spelled it wrong, thanks Speedy

    And thanks heaps XSquared, even if your not the words greatest, your still probably better than me and thats what counts. But if Salem or Prelude want to look at it too, I'd be very grateful

    Edit: Just got a new developer on the team to create a configuration app in VB. As soon as ISAPI is implemented and I sort out a few piping problems, a version 1.0 release will be ready!
    Last edited by nickname_changed; 08-24-2003 at 01:03 AM.

  15. #15
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Hey, XSquared (or anyone), could you please look at the functions:
    CONNECTION::SendBinary() and CONNECTION::SendText()?

    It seems that after sending a file, I cannot delete it because I get told the file is already in use I don't understand how, since I call hFile.close(), so they should close fine. Any ideas why?

    EDIT:
    Lurker (or anyone else), if your interested in creating web servers, your welcome to join the SWEBS project. It would be nice to have more C++ programmers around, and it would be a nice learning experience for you. If you are then PM me for further information.
    Last edited by nickname_changed; 08-25-2003 at 06:15 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. intercepting packets for web servers and replying back
    By liri in forum Networking/Device Communication
    Replies: 1
    Last Post: 10-21-2007, 10:43 PM
  2. Processor Vendors for web servers
    By Lind in forum Tech Board
    Replies: 8
    Last Post: 10-08-2007, 05:22 AM
  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. Good Web Servers
    By mill1000 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 11-19-2002, 09:16 PM