VB - A simple HTTP Web Server (2)-VBForums
Results 1 to 18 of 18

Thread: VB - A simple HTTP Web Server (2)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,726

    VB - A simple HTTP Web Server (2)

    This is an improved version of the server in this thread:
    http://www.vbforums.com/showthread.p...hreadid=237843

    I added a function to list directories and files if the user does not type any file name in the link.

    To make it work, you have to change the LocalPort to whatever port you want the server to listen for connections, and PathShared constant to a valid directory.

    To see it in action, type the local ip then ":" and the local port, for example: http://127.0.0.1:8080
    Attached Files Attached Files

  2. #2
    New Member
    Join Date
    Apr 2008
    Posts
    1

    Re: VB - A simple HTTP Web Server (2)

    Hi and thanks heaps for this. I already had a socket based server program but I'm not an expert in Http so wasn't sure on the header information to pass back.

    To this end, wondering if anyone can help me.

    I have a need to connect to my existing "server" which performs a wide variety of tasks via a normal socket connection (local tcp).

    This has changed and I need to connect via a web page. No problem, just include the web server code above and problem solved..... almost.

    I need to do a comet style slow load technique in order that my "server" program can send status messages back to the browser, reverse ajax style.

    I have the javascript code this this already that sets up the xmlhttprequest objects etc, but as I am not very compentant in http, I am unsure how to make the server side hold the connection open (well, ok I got it to jam on one connection but bad things happened). Nor what format in order to push the data back to the client.

    Any help anyone has, or pointers in the right direction would be greatly appreciated. I feel that the above code should be able to do it with some minor mods as I'm running quite a dedicated process and does not have to perform any other tasks except send and receive basic messages.

    Thanks

    Michael

  3. #3
    New Member
    Join Date
    Sep 2008
    Posts
    1

    Re: VB - A simple HTTP Web Server (2)

    Excelent work! i have too a http server but it is better than mine, i will use it in my proyects

    bye

  4. #4
    New Member
    Join Date
    Sep 2009
    Location
    Scotland, UK
    Posts
    4

    Re: VB - A simple HTTP Web Server (2)

    Very smart, well constructed and commented piece of code.
    Well done!
    I was sooooo very close to putting something remarkably similar to this together....
    I eat and sleep sockets stuff, but the HTML / HTTP handling bits saved me a couple of days getting the "basics" sorted out.
    Thanks again

  5. #5
    New Member
    Join Date
    Nov 2009
    Posts
    1

    Re: VB - A simple HTTP Web Server (2)

    Cleaned up version of the above code.
    Uses DoEvents for event handlers that call each other
    Open files closed on WinSock_Close event
    A couple of programming form improvements
    Configuration window

    Removed all the commenting, sry :P
    Attached Files Attached Files

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,726

    Re: VB - A simple HTTP Web Server (2)

    Welcome to the forums...

    But... what's with DoEvents ? the only purpose I see for DoEvents is to slow down the application... and to mess up the data on DataArrival...

    As most of the code I write for the CodeBank, I write with a purpose... This time the purpose was to show how to make a simple web-server, not how to save the settings, or logs, etc... that can be done on your own (as you did) after you learn the important part... and it seems like you did... therefore I did my part well.

    I could have added all the bells and whistles too, but I wanted to make it as simple as possible so that anyone could understand how a web-server works.

  7. #7
    Hyperactive Member
    Join Date
    Oct 2008
    Posts
    481

    Re: VB - A simple HTTP Web Server (2)

    Why would I use any server other than Apache? Apache ROCKS!

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,726

    Re: VB - A simple HTTP Web Server (2)

    I think maybe I should ask the Admin to lock this thread... things are getting out of hand here...

  9. #9
    New Member
    Join Date
    Sep 2009
    Location
    Scotland, UK
    Posts
    4

    Re: VB - A simple HTTP Web Server (2)

    LOL - I agree! The original post served it purpose extremely well. As said before - it saved a good bit of research time. Thanks again.

  10. #10
    New Member
    Join Date
    Feb 2010
    Location
    Suburb of Backwoods
    Posts
    3

    Re: VB - A simple HTTP Web Server (2)

    CVMichael,
    Kudos galore -
    This "Simple HTTP Web Server" is an excellent example.
    It has demystified the entire concept for me. I didn't know that HTTP communication was so simple an ASCII format, let alone how to see any of it.
    (how do you spell epiphany, anyway?)
    Now that I've got my new pointy-hat, I'm going full speed.
    Thanx much
    WDave

  11. #11
    Member
    Join Date
    Sep 2008
    Location
    Turkey
    Posts
    37

    Re: VB - A simple HTTP Web Server (2)

    Really Good Job...

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,726

    Re: VB - A simple HTTP Web Server (2)

    Thanks...

  13. #13
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    Re: VB - A simple HTTP Web Server (2)

    thanks CV for this code

    I want to add some more implementation but am confused about how to go doing it.

    can you suggest how i add thes features:

    Mapping redirectsn,Directory Listing , and Logging

    thanks
    Programming is all about good logic. Spend more time here


    (vHost for Apache) (Generate pronounceable password) (Generate random number c#) (Filter array with another array)

  14. #14
    Lively Member
    Join Date
    Apr 2009
    Posts
    94

    Thumbs up Re: VB - A simple HTTP Web Server (2)

    Great Project

    Can you add PHP MySql Support in this project.

    Thanks Again.
    I belive in pray. I pray for you.
    You may have happy, healthy, wealthy life.

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,726

    Re: VB - A simple HTTP Web Server (2)

    I wouldn't even if I knew how... but I don't know how...

    I don't have time to make any improvements to any projects I posted on the vbforums. My interests are different now. Though I do help once in a blue moon with quick questions.
    And besides, I don't program in VB6 anymore, I switched to VB.NET...

  16. #16
    Member
    Join Date
    Nov 2006
    Posts
    39

    Re: VB - A simple HTTP Web Server (2)

    How can I port this source to VBA (i.e. Excel macro)?
    Just being able to display a "hello world" messagebox upon receiving a character on port 80 would be enough for me to have something to start from to write the program I need!

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,726

    Re: VB - A simple HTTP Web Server (2)

    LOL, so then anyone who you give this Excel file will have a port open to get/send data... I don't think so...

  18. #18
    Member
    Join Date
    Nov 2006
    Posts
    39

    Re: VB - A simple HTTP Web Server (2)

    Quote Originally Posted by CVMichael View Post
    LOL, so then anyone who you give this Excel file will have a port open to get/send data... I don't think so...
    what are you talking about?!?

    I want to open port on MY pc to be accessed from outside!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.