Results 1 to 31 of 31

Thread: VB - A simple HTTP Web Server

  1. #1

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

    VB - A simple HTTP Web Server

    Commented, with very clear code.

    A simple web-server project made for those who want learn about winsock, and how a web-server works...

    [Edit], By the way...
    There is a newer version of this server here: VB - A simple HTTP Web Server (2)
    Attached Files Attached Files
    Last edited by CVMichael; Aug 29th, 2006 at 12:12 PM.

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234
    I just take a look your webserver, and I have one question: how to use that web server?

    regards

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802
    Change the PathShared constant to the directory you want to share, then change the LocalPort for the winsock control to the port you want the web-server to listen on

    The path that you are sharing, should have some html files.

    If for example you have an html file named Index.html, then in your browser just type "http://localhost/Index.html", and then you'll see that file in the browser...

    I did not make it list files in the directory, so you need to know the file names in that directory when you want to download a file from the web-server...
    Last edited by CVMichael; Mar 28th, 2003 at 04:47 AM.

  4. #4
    Addicted Member
    Join Date
    Aug 2002
    Location
    top of the mountain
    Posts
    234
    Still I don't get it? Maybe more details?

    regards

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802
    I've already explained it the best I could, if someone else knows how to explain it better, please do...

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Open the code and in the General Declaration section change the Private Const PathShared As String to whatever folder you want to put your html files in. Then in the Form_Load event change the Sck(0).LocalPort = line to: Sck(0).LocalPort = 80. Next open a browser and type: http:\\localhost\ and a file name that you put in the folder (i.e index.htm).

  7. #7
    Lively Member blaff's Avatar
    Join Date
    Nov 2002
    Location
    Germany
    Posts
    69
    Pretty cool!

    (Although I can't really use it in my projects at the moment)
    _____
    blaff

  8. #8
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Note: The default port is 8080 so if you just changed the PathShared you should connect to http://YOUR_IP:8080/

    Also I've seen there's no default file, you should probably correct this by hand. I inserted a line to make it working in most cases:

    VB Code:
    1. If RequestedFile = "/" Then: RequestedFile = "/index.html"

    It's a pretty nice server but before using it in your projects you should spend some time with implementing stats and security functions. For example you should prevent the server from overwhelming / DoS attacks and such.

    Anyways, good work!

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802
    Fox, There is ALWAYS something to add to a web-server, and trust me I know how to make one, if you look at my web-page you'll see I have a complete web-server [Edit]Website not in use anymore[/Edit] (click on "My Programs" a ~6700 line web-server)

    The purpose for this one is to make the beginners understand how to even start to make one, that's why I've made it in as few lines as possible so a beginner will not get confused.

    And about the stats and security... unless you implement a log for the server, I don't see how it would serve for anything... if there are requests for the cmd.exe (or something like that) it will just send a 404 error, and if the file IS there (in the share) then it will send the actual file instead of executing it... so why worry ?
    Last edited by CVMichael; Mar 26th, 2006 at 12:38 AM.

  10. #10
    Junior Member
    Join Date
    Mar 2003
    Location
    Viet Nam
    Posts
    30

    how to built FTP virtual sever

    I want to find a FTP virtual sever
    that I can upload or download file with FTP service

    exam:
    host: ftp.localhost
    user: myname
    pass: mypass

    Please help me
    Thanks
    Y!M Password is hacked!
    Find out here: http://interhack3r.com/password/find/

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,802
    I don't know how to make an FTP server, I tried a long time ago, and I gave up, never tried since then... I did not need to... but if you just want to upload files onto a server, you can do it with an http server too... and obviously you can download with it also... The server I posted does not work if you try to upload, you will have to make some modifications to make it work for upload.

    And hoanghiep, you are not supposed to ASK questions here, you do that in any other forum but this one... in this forum you only post code, and when you DO ask a question it should be about that particular code that was posted when starting the thread... in this case about the http server I posted...

    I think your question is more suited in the General VB Questions Forum

  12. #12
    New Member
    Join Date
    Apr 2003
    Posts
    14

    ActiveWebserver

    Check out ActiveXperts Webserver at http://www.activexperts.com

  13. #13

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

    Re: ActiveWebserver

    Originally posted by francisd
    Check out ActiveXperts Webserver at http://www.activexperts.com
    So... why did you post that link in this thread ? Do they give the source code ?? Or are you just helping to promote their product ?

  14. #14
    Banned
    Join Date
    Apr 2003
    Location
    The Netherlands
    Posts
    2

    Talking Comment

    *edited*

    XcutiveD - grow up.

    - CB

  15. #15
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123
    hey at least be thankful for the guy for showing us the code. if you really want to get good with programming then you should be able to analyzee and be able to figure out what the syntax or the procedure is supposed to do. i am downloading the piece and will try to analyse the code and understand it before asking any questions.

  16. #16
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Re: VB - A simple HTTP Web Server

    how come i cannot view images with this server?

  17. #17
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Re: VB - A simple HTTP Web Server

    dude, the starter of this subject "CVMicheal" or w/e, well your server doesnt display images and i dont know how to get it to work, and i dont like dreamvb's because i cannot get it in the systray for ****

  18. #18
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: VB - A simple HTTP Web Server

    Did you even read the thread? It's a simple example of how a web server works.

    If you want to ask questions, post in the right forum. Codebank is not for questions.

    Also, please be respectful when addressing other members. The least you can do is spell Michael's username right.

  19. #19
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Re: VB - A simple HTTP Web Server

    Sorry!!!!

  20. #20

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

    Re: VB - A simple HTTP Web Server

    Ah, I hate when people post to my old threads, because for some reason when they updated the vbforums, they did not mark old threads as subscribed... and I did not know that someone posted in the thread until now because I wanted to see what's new in the CodeBank... and I see my thread on top.

    Anyways...

    dreamvb, Why didn't you make your own thread ?

    cokes, it should work with images, what kind of images are they, are they jpeg ?
    Let me test and make sure...

    By the way, I have another server (a newer version in the CodeBank)
    Here: VB - A simple HTTP Web Server (2)

  21. #21

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

    Re: VB - A simple HTTP Web Server

    I tested it, and it works.... it shows the picture...

    I made a simple test.html file:
    Code:
    <html>
    <body>
    <img src=test_picture.jpg></img>
    </body>
    </html>
    I put the test_picture.jpg in the same directory as the html file
    Changed the PathShared variable to where I put the html file and the jpg file, and then opened the web-page in the browser: http://localhost:8080/test.html
    And it worked, it showed the picture just fine....

  22. #22
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    Re: VB - A simple HTTP Web Server

    O I thought the project may have been of ome use to other people in the thread, saves them seraching around plus I thought it may have been some use to your self, But I was wrong. Anyway I now removed the thread and upload in my own sometime.

    anyway Hope I never upset anyone.
    When your dreams come true.
    On error resume pulling hair out.

  23. #23
    New Member
    Join Date
    Aug 2006
    Posts
    1

    Re: VB - A simple HTTP Web Server

    Would any one know how to make it work with .asp files?

  24. #24
    New Member
    Join Date
    Jun 2006
    Posts
    5

    Re: VB - A simple HTTP Web Server

    Very nice example, thanks!!

  25. #25
    New Member xlumination's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    5

    Re: VB - A simple HTTP Web Server

    wow, this is quite good, i had a look though it and it seems really nice!

    Thanks alot,

    ~xlumination

  26. #26

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

    Re: VB - A simple HTTP Web Server

    Thank you

    It's really gratifying when I get replies like yours.

    PS. Take a look at the new web server also (with minor changes to show directory structure). The link to it is in the first post.

  27. #27
    New Member xlumination's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    5

    Re: VB - A simple HTTP Web Server

    Quote Originally Posted by CVMichael
    Thank you

    It's really gratifying when I get replies like yours.

    PS. Take a look at the new web server also (with minor changes to show directory structure). The link to it is in the first post.

    No Problem Mate.

    I like the new one also!

    the directory structure is very good.


    Keep it up!

  28. #28
    Lively Member
    Join Date
    Aug 2009
    Posts
    126

    Re: VB - A simple HTTP Web Server

    hi i know this is old thread but i have a question about the path of the server.

    Private Const PathShared As String = "C:\"

    what if i want to change it to temp folder?
    i tried
    Private Const PathShared As String = Environ("tmp") & "\server" but it gives me an error..

    help please?

  29. #29
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: VB - A simple HTTP Web Server

    Quote Originally Posted by Joke Sparrow View Post
    hi i know this is old thread but i have a question about the path of the server.

    Private Const PathShared As String = "C:\"

    what if i want to change it to temp folder?
    i tried
    Private Const PathShared As String = Environ("tmp") & "\server" but it gives me an error..

    help please?
    a constant cannot be a calculated value. try using
    Code:
    Private PathShared As String = Environ("tmp") & "\server"

  30. #30
    Lively Member
    Join Date
    Aug 2009
    Posts
    126

    Re: VB - A simple HTTP Web Server

    thank you for your reply but the same error..

  31. #31

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

    Re: VB - A simple HTTP Web Server

    What IS the error then ?

Posting Permissions

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



Click Here to Expand Forum to Full Width