Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2005

Tip: Looking for answers? Try searching our database.

making an http server

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
lucifer - 30 Nov 2005 16:53 GMT
hi
i am making an http server
it has following functions
main()
{
if option is "-?", output the hints and stop
check the directory supplied is sensible and not a security risk
become a daemon process
ignore child programs (to avoid zombies when child processes stop)

create a socket, bind it to a port number and start listening to the
socket

forever {
            wait and accept incoming socket connection
            start a new thread
            web function
            else close new connection
    }
}

log()
{
outputs error, sorry or log messages to the nweb.log file
if a sorry message, transmit it to the browser as a fake HTML response
if error or sorry message the program is stopped
}

web()  - this function returns the request back to the browser
{
read from the socket the HTTP request
check it's a simple GET command
check no parent directory requested to escape the web servers home
directory
if no file name given assume index.html
check the file extension is valid and supported
check the file is readable by opening it
transmit the HTTP header to the browser
transmit the file contents to the browser
sleep thread for 1 second
stop
}
mine problem is how can i start a new thread for every new request i
recieve
plz help
Cowboy (Gregory A. Beamer) - 30 Nov 2005 16:57 GMT
Probably some hints here:
http://www.asp.net/Projects/Cassini/Download/Default.aspx?tabindex=0&tabid=1

Signature

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***********************************************
Think Outside the Box!
***********************************************

> hi
> i am making an http server
[quoted text clipped - 41 lines]
> recieve
> plz help
Ignacio Machin ( .NET/ C# MVP ) - 30 Nov 2005 19:20 GMT
Hi,

You can use a sync queue  for example, in your main thread (the one
accepting connections) each time a new connection is received the TcpClient
(or Socket) is stored in a Sync'd Queue, a new thread is spawn to execute
the serving methid, this method dequeue the first element from the queue and
it's the sockets it uses

cheers,

Signature

Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

> hi
> i am making an http server
[quoted text clipped - 41 lines]
> recieve
> plz help

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.