Quick Search for:  in language:    
ANY,BUGS,example,project,create,server,looked
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,290,928. lines
 Jobs: 207. postings

 How to support the site

 
Sponsored by:

 
You are in:
 

Does your code think in ink?
Login





Latest Code Ticker for Visual Basic.
Control By Browser
By Priyan R on 12/30


Stealth Exchange SFX
By dvchaos on 12/30


Click here to see a screenshot of this code!Mini Tetris
By Code Toad on 12/30

(Screen Shot)

Click here to see a screenshot of this code!NTMessager Network Message Utility
By B.Cem HANER on 12/30

(Screen Shot)

Math-Game
By Angelica Courtin on 12/30


Click here to see a screenshot of this code!Encryptor Xor Version 3
By DISTS on 12/30

(Screen Shot)

Click here to see a screenshot of this code!Stretch Image Two Times !! (Using GetPixel and SetPixel)
By Skinny Ugly Guy on 12/30

(Screen Shot)

Simple FileFind Class Object
By David Jonathan Messervey on 12/29


Font Rotator Module
By Lyox Soft on 12/29


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Web Server example Code version .3a FIXED (2nd)

Print
Email
 
winzip icon
Submitted on: 12/19/1999
By: Pat 
Level: Intermediate
User Rating: By 3 Users
Compatibility:VB 5.0, VB 6.0

Users have accessed this code 8949 times.
 
 
     This is an example project on how to create a web server. I looked on this site and haven't seen any, so i decided to make one. I commented everythign as much as i could. Let me know what you think about it :) This code has been updated. I removed the pause of .4 seconds and moved the code to sckWS_SendComplete. I want to thank Ron for letting me know that it would slow it down. :) Please post any suggestions/improvments or just your thoughts on it. :) 'v .2a fixed: some loading problems 'v .3a fixed: fixed the $ip linking problem, everything works now. :) ' also fixed: i made the project compatible with vb5 by removing the replace ' function. ' Creating a link to another page ' To link to another page, link to 'http://$ip/page_name.html' 'The webserver will replace $ip with your ip. The webserver also 'supports files in other directories in the html dir. You could link 'to test.html in the directory 'links' by linking to: ' http://$ip/links/test.html ' ' PLEASE REPORT ANY BUGS! ' pat - nymainst@nais.com Please visit my webpage @ http://momar.net/pat :)
 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.

Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:
1)Re-scan downloaded files using your personal virus checker before using it.
2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
3)Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
12/19/1999 9:17:17 PM:Limbokid
Absolutely incredible!  Nice code, 
simple interface and - what a nice 
feature - IT WORKS!
Keep up the 
awesome work :)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/19/1999 9:21:38 PM:Pat
Why thank you :)  I hope you understood 
it.  At a point when i get a chance, 
i'll probably code some other things i 
haven't seen on here with winsock 
:)
Please rate my work if you like 
it, it makes me feel *special*, lol :)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/19/1999 10:49:33 PM:Omar
Please Keep It Up!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/19/1999 10:55:41 PM:Ron
Great Code Dude..
Keep It UP.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 12:44:11 AM:Ron Serber
Good work,
Why are you using the 
timeout 0.4
Is there a more elegant 
way to do this?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 12:48:19 AM:Pat
You have to pause after sending the 
data, then close the connection.  i've 
found that .4 seconds works best :) 
yes, there is a more elegant way to do 
this though.  You'd need to code 
something into the 
sckWS_TransferFinished sub. :)  i was 
thinking about doing it.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 5:14:19 AM:Amritanshu
Great Code man....
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 9:43:14 AM:EnCrY
"clap" , "clap" , "clap", "cLAP"
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 1:48:34 PM:Ahmad Hosseini
I get run time erro 10048.
Address in 
use.
What does it mean.  How can I 
resolve it.
Thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 3:24:21 PM:Brandon
Pat I dont know if you will read this 
first before you check your email but 
if you do then check your email right 
now for my question please
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 3:52:30 PM:Pat O'Laughlin
Very nice example.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 7:40:20 PM:Jason
This code doesnt work in VB 5.0 Because 
VB 5 does allow the Replace 
command.
Also VB 5 needs the 
"Retained" key removed... 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 7:55:10 PM:SlyOne
Hey Ahmad Hosseini the solosion(Don't 
know how to spell) to the error 10048 
is reinstall the adapter that the app 
is running off that has TCP/IP.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 8:24:58 PM:Millenium Software
Excellent code! This is the first web 
server I've seen in VB that works so 
well. 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 11:27:07 PM:jared
well done pat. i used some of your 
ideas and the basic layout of your form 
to create a server more adapted to my 
needs. i added command line switches 
for easy startup/minimization upon 
loading... as well as a tray icon and 
animated tray 
minimization.
screenshot - 
http://24.48.73.8/
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/20/1999 11:33:45 PM:Omar
Thanks for that bug fix Pat
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/21/1999 3:56:54 PM:No0ne
Nice! And well put together.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/22/1999 1:41:41 PM:Tj
Really cool,really cool!!!
The best 
code I have seen here...
Keep on the 
great work...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/23/1999 6:53:28 PM:Rob
When there are pictures on the pages, 
they do not load.  Does that require 
extra coding?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/30/1999 8:30:39 AM:anders
Rob is right, the pictures dos'nt load, 
please fix it. Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/4/2000 1:46:21 PM:JMDickson
Every get loads a new winsock, even 
when the others are not in use.  This 
eats about 4k per get that is never 
released.
To use images replace 
text_read with:
Public Function 
text_read(filename)
Dim intFileNum 
As Integer
Dim strFile As String
Dim 
lngLength As Integer
  On Error 
Resume Next
  intFileNum = FreeFile
strFile = ""
  If FileExists(filename) 
Then
    If Len(filename) Then
Open filename For Binary As #intFileNum 
  ' Open file.
      strFile = 
Space(FileLen(filename))
      Get #1, 
, strFile
      Close #intFileNum
End If
  End If
  text_read = 
strFile
End Function
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/5/2000 6:01:37 AM:plotoder
any idea on how to run cgi scripts with 
this one
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/7/2000 5:19:06 PM:joox
if you want a webserver which support 
images. download this one:
<a 
href="http://www.planet-source-code.com/
vb/scripts/ShowCode.asp?txtCodeId=5193">
webserver
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/10/2000 2:02:19 AM:Mitch
Great Code but could have some better 
error handling. Also going to 
http://<ip>/../ will freeze the server. 
Anyway to fix this? And also, is there 
any way to list the files, as in FTP? 
Thanks :) [webmaster@mitch.zzn.com]
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/17/2000 4:55:56 AM:Neil Ramsbottom
I have just started my own webserver 
project and this answers quite a few of 
my question. Lemme know if you need a 
VB5 coder.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/17/2000 2:10:05 PM:SB
Hey, good Idea Wizdum.. you wanna see 
his mad skillz at work? Goto 
www.theblackhand.net and download this 
work of art
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/18/2000 12:56:03 PM:Alex
I've a question, when I typ http://(My 
I.P.)/Index.html the server says that 
someone is connected but in internet 
explorer ther is no page vissible. The 
server and the html files are in the 
same directory, does anyone know what 
I'm doing wrong?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/18/2000 2:41:21 PM:Brian
Is this for VB 6 only, I have VB 5.0 
and can not open the project. I recive 
a "Retained" invalid key error?
Help 
Please!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/18/2000 2:55:38 PM:Brian
I think I know what the problem is 
know... the reference lines in the 
project file are pointing to files in 
the ..\..\..\WINDOWS\SYSTEM directory 
which of course will cause the errors I 
am getting becuase I use NT and there 
for do not have a windows directory 
per-say... I changed that, and it seems 
to function ;)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/23/2000 11:44:42 AM:Jack Edin
Great work! Thank you.
I needed a 
working example of a Winsock Listener 
to modify into something completely 
different than a webserver...
Luckily 
for me I built on THIS fine piece of 
work! Couldn't have done it without ya, 
buddy... Thankx again!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/24/2000 10:16:12 AM:Me
Hey Brian, If you got a "retained" key 
when opening in VB5, try this:
1) Open 
up notepad  
2) Open up the .vbp of 
this code
3) Delete the line near the 
bottom that says "retained=..."
4) 
Save it and open the project in VB and 
your fixed up.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/28/2000 7:19:45 AM:josh
great example code, just one question 
though, your example always lists my ip 
as: http://4.0.0.3, for some reason, it 
will work fine if I go to my actual ip 
addy but links won't work because it 
thinks my ip is the one above is this 
because I am on a proxy server? and is 
there anyway to fix it?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/29/2000 1:27:12 AM:Jim
I love your code but is there any way 
to make it more stable? It is so easy 
to lockup the program. All you need to 
do is type something wierd into the 
browser and the web server program 
freezes. i.e. type 
http://127.0.0.1//
or
http://127.0.0.1
/..
Would you need to filter out 
every possible bad command or is it 
possible to just check if it is valid?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/8/2000 7:21:43 AM:Fred
Just one thing, the way you said to 
change the 404 error so that it loads a 
html 404 error page for me does not 
work, it just makes a page with the 
directory of the html page is there a 
way to fix this? does this happen for 
anyone else or just me?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/8/2000 10:34:33 PM:sub
Fred you need to change part of the 
sckWS_ConnectionRequest sub as well, 
the part I am reffering to should look 
like this:
 requestedPage$ = 
html_404$
      htmldata$ = 
text_read(htmlPageDir & "\" & 
"404.html") 'This reads the file and 
stores it's contents in htmldata$
 htmldata$ = ReplaceStr(htmldata$, 
"$ip", sckWS(0).LocalIP) 'Oops, i 
didn't use the replace function right.  
Now it's fixed at replaces $ip with 
your IP.
sckWS(ttlConnections).SendData 
htmldata$ & vbCrLf
instead of 
this(this is off the top of my head so 
may be wrong):
requestedPage$ = 
"/a"
sckWS(ttlConnections).SendData html_404$
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/18/2000 12:40:37 PM:ap
man.. this is great...what else can i 
say
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/8/2003 8:26:33 AM:ykristiawan
Very good one, 5 globes from me. Are 
you planning to enhance your program to 
handle HTTP POST?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.