473,411 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

making an http server

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

Nov 30 '05 #1
2 1889
Probably some hints here:
http://www.asp.net/Projects/Cassini/...ndex=0&tabid=1

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

***********************************************
Think Outside the Box!
***********************************************
"lucifer" <um**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Nov 30 '05 #2
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,

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

"lucifer" <um**********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Nov 30 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fuzzyman | last post by:
In a nutshell - the question I'm asking is, how do I make a socket conenction go via a proxy server ? All our internet traffic has to go through a proxy-server at location 'dav-serv:8080' and I...
1
by: Erwin S. Andreasen | last post by:
I have a Python application server that manages several different data sets, permits various reports to be run on them and the data to be downloaded as tab-delimetered files, all via a web...
3
by: Mark Adams | last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail server running for several months. It took me a week or so to get it up and running in September. Now, I did a clean upgrade to...
5
by: Paul Mason | last post by:
Hi folks, We have two servers running ASP.NET systems. One is live and one is development. I have recently adopted an ASP system from a colleague to nurse it back to health. On the...
8
by: McGrull | last post by:
Sorry for my question, but I'm really a newbie on ASP. I need to make a simple page (for IIS 5.0 and up, but even for 2000 Professional IIS) that read and display the files contained in a...
5
by: Charlie | last post by:
Hi: I'm working on an e-commerce site. Using the SMTP class, my site sends out confirmation messages. It works most of the time, but sometimes raises an error. I need a way of making sure it...
0
by: Mike Cox | last post by:
Hi. As most of you know, comp.databases.postgresql.general is a wonderful resource. What you may not know is that it has not gone through a process that would enable it to be listed on hundreds...
3
by: Yong | last post by:
I get a general network error when I try to make asynchronously call ExecuteNonQuery on long sql statements that run in parallel. Here is the background info on what I'm trying to accomplish: I...
0
by: Dan | last post by:
Issue making textbox visible based on specific input from a radio button list in an EditItemTemplate I want to setup a gridview that when in edit mode and when the user selects "Other" from a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.