SlideShare a Scribd company logo
1 of 23
Fun Fun Project One 1
Fun Fun Project One
Building Your Very Own Web
Server
Fun Fun Project One 2
What is a Web Server?
 Program that understands the HTTP
protocol and generates appropriate
responses
 Clients “connect” to the machine
 Clients send a “request”
 Server reads request, generates
“response”
 Client interprets response appropriately
Fun Fun Project One 3
A Simplified Web Server
 Client asks for file
 Server finds appropriate file
 Server sends back a response header
followed by the requested file’s data
 Server closes connection
Fun Fun Project One 4
What Does “Connect” Mean?
 For all practical purposes, it looks like
there’s data available via a file
descriptor
 Stream of bytes
 Can be treated like any other file descriptor
 Not a FILE * (like stdio, stderr)
 Must use read() and write() system calls
Fun Fun Project One 5
How Do You Identify
Machines
 Domain names/IP address and ports
 http://www.cs.princeton.edu implies a
machine named www.cs.princeton.edu
and a default port of 80
 http://127.0.0.1:8080/index.html
 Refers to local box (127.0.0.1 is me)
 Port # is 8080 (used for this project)
 File is named index.html
Fun Fun Project One 6
How Do You Identify Files?
 File name is specified in Request
Message
 Server maps that name to a real file
 Mapping can be done in whichever way
server wants
 For example, /~vivek/index.html is
actually
/n/fs/fac/vivek/public_html/index.html
 In your web server, you can choose your
own
Fun Fun Project One 7
What’s In A Request Message?
GET /index.html HTTP/1.0rn
Connection: Keep-Alivern
User-Agent: Mozilla/4.72 [en] (X11..)rn
Host: 127.0.0.1:31415rn
Accept: image/gif, image/jpeg, */*rn
Accept-Encoding: gziprn
Accept-Language: enrn
Accept-Charset: iso-8859-1,*,utf-8rn
rn
Fun Fun Project One 8
What Do You Care About?
GET /index.html HTTP/1.0
In particular, just index.html
Assume “/” means “/index.html”
Fun Fun Project One 9
What Could They Want?
 An honest-to-goodness file (me.jpg)
 An indirect request for such a file (such
as “/” meaning index.html)
 An implied directory with index
(/home/vivek instead of /home/vivek/)
 Just a directory listing
 A query (we don’t care about these)
 An invalid/nonexistent file
Fun Fun Project One 10
What’s In A Response
Message?
HTTP/1.0 200 OKrn
Date: blah-blah-blahrn
Server: blah-blah-blahrn
Content-Type: importantrn
Content-Length: 12345rn
Last-Modified: blah-blah-blahrn
rn
Raw data
Fun Fun Project One 11
What’s a Minimal Response?
HTTP/1.0 200 OKrn
Content-Type: stuffrn
rn
Data
HTTP/1.0 302 Movedrn
Location: newurlrn
rn
HTTP/1.0 404 Not Foundrn
rn
But also
Connection: closern
Content-Length: yyyrn
Fun Fun Project One 12
Response when…
 File exists? Send it
 Directory without “/” suffix? Redirect
 Directory with index.html? Send it
 Directory with no index.html? List it
 For each list entry, add “/” if needed
 Failure(Not Found)? Send 404
 Bad Request? Send 400
Fun Fun Project One 13
How to Test Your Server?
 Use a browser(Netscape/IE)
 Use “wget”
 Support HTTP protocol
 http://www.gnu.org/manual/wget
 create directory hierarchy for retrieving
 Include some big images
Fun Fun Project One 14
More Test Cases
 What if Request Message is not
send/received in one packet…
 The server must read all the Request Messages
before it gives any response message
 Remember the double carriage return and line
feed?
 Your web server must consider this!
 I’ll distribute more test programs later on,
check
http://www.cs.princeton.edu/~yongwang/cos318
Fun Fun Project One 15
What is Content-Type?
text/html
image/gif
image/jpeg
(Other types not needed for project 1.)
Fun Fun Project One 16
Need more info?
HTTP 1.1 Specification – RFC2068
HTTP 1.0 – RFC 1945
man pages
man man
man –k blah
read( ), write( ), open( ), close( )
Fun Fun Project One 17
Why open instead of fopen?
 Compare fopen, fread, etc., with open,
read, etc
 We’re dealing with functions closer to
the OS – easier to use in some cases
Fun Fun Project One 18
What’s a File Descriptor?
 Sort of like a FILE *
 It’s an integer provided by OS
 Used to represent a stream of bytes
 Can represent file or network connection
 Behavior is slightly different
 Especially when reading/writing network
Fun Fun Project One 19
General Steps
Setup, and then
 Get next connection
 If file, read from disk
 If directory, generate listing
 Send all to client
 Close connection, wait for next
one(nonpersistent connection)
Fun Fun Project One 20
What Am I Given?
 Setup function
 Makes server available for connections
 Accept function
 Gets a connection from a client
 File type function
 Tells you what kind of file, if it exists
 Tells you how many bytes if a regular file
 Directory listing functions
 Gives you the file names one at a time
Fun Fun Project One 21
Help! I’m Lost!
 Don’t know HTML?
 Use Netscape composer to see what to do
 View page source for various pages
 Do “telnet www.domain.com 80” and issue
the GET manually (need to add “Host:
www.domain.com” header)
 Ask
Fun Fun Project One 22
Why Are We Doing This?
 Infrastructure for future projects
 Some OS/Networking interaction
 It’s fun, and not too bad
Fun Fun Project One 23
Wrap Up
 Thanks!
 Q&A session next week!
 Office Hour: Wed 4:30-5:30

More Related Content

What's hot

What's hot (20)

Url and protocol
Url and protocolUrl and protocol
Url and protocol
 
Powerpoint Web Admin 2
Powerpoint Web Admin 2Powerpoint Web Admin 2
Powerpoint Web Admin 2
 
HTTP & HTML & Web
HTTP & HTML & WebHTTP & HTML & Web
HTTP & HTML & Web
 
File accessing modes in c
File accessing modes in cFile accessing modes in c
File accessing modes in c
 
An Introduction To World Wide Web
An Introduction To World Wide WebAn Introduction To World Wide Web
An Introduction To World Wide Web
 
How web crawlers work
How web crawlers workHow web crawlers work
How web crawlers work
 
Url Presentation
Url PresentationUrl Presentation
Url Presentation
 
Abeer Elshahat
Abeer ElshahatAbeer Elshahat
Abeer Elshahat
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
PHP file handling
PHP file handling PHP file handling
PHP file handling
 
Delphi L05 Files and Dialogs
Delphi L05 Files and DialogsDelphi L05 Files and Dialogs
Delphi L05 Files and Dialogs
 
Server Logs: After Excel Fails
Server Logs: After Excel FailsServer Logs: After Excel Fails
Server Logs: After Excel Fails
 
Structure of url, uniform resource locator
Structure of url, uniform resource locatorStructure of url, uniform resource locator
Structure of url, uniform resource locator
 
World Wide Web
World Wide WebWorld Wide Web
World Wide Web
 
Wireshark http solution_v6.1
Wireshark http solution_v6.1Wireshark http solution_v6.1
Wireshark http solution_v6.1
 
Uniform Resource Locator (URL)
Uniform Resource Locator (URL)Uniform Resource Locator (URL)
Uniform Resource Locator (URL)
 
Web data from R
Web data from RWeb data from R
Web data from R
 
World Wide Web(WWW)
World Wide Web(WWW)World Wide Web(WWW)
World Wide Web(WWW)
 
Bittorrent
BittorrentBittorrent
Bittorrent
 

Viewers also liked

( 1 )تابع المتتابعات الحسابية
( 1 )تابع المتتابعات الحسابية( 1 )تابع المتتابعات الحسابية
( 1 )تابع المتتابعات الحسابيةnoojy66666
 
Business models for effective market update of EE services
Business models for effective market update of EE servicesBusiness models for effective market update of EE services
Business models for effective market update of EE servicesLeonardo ENERGY
 
Fundraising-science-to-stewardship
Fundraising-science-to-stewardshipFundraising-science-to-stewardship
Fundraising-science-to-stewardshipSusan Larson
 
Brais marina jose jonatan
Brais marina jose jonatanBrais marina jose jonatan
Brais marina jose jonatannatitaboas
 
Vipin Kumar dip.chemical
Vipin Kumar dip.chemicalVipin Kumar dip.chemical
Vipin Kumar dip.chemicalVipin Kumar
 
The IEA Energy Efficiency Market report - What it means for DSM
The IEA Energy Efficiency Market report - What it means for DSMThe IEA Energy Efficiency Market report - What it means for DSM
The IEA Energy Efficiency Market report - What it means for DSMLeonardo ENERGY
 
Crisis de candidatos Columna Semanal del Diputado Waldo Fernandez
Crisis de candidatos Columna Semanal del Diputado Waldo FernandezCrisis de candidatos Columna Semanal del Diputado Waldo Fernandez
Crisis de candidatos Columna Semanal del Diputado Waldo FernandezPablo Carrillo
 
Lista cotejo portafolio_digital aleja
Lista cotejo portafolio_digital alejaLista cotejo portafolio_digital aleja
Lista cotejo portafolio_digital alejaAleejaandra Goodoy
 
Future Electricity Markets: key pillars with high shares of wind and PV
Future Electricity Markets: key pillars with high shares of wind and PVFuture Electricity Markets: key pillars with high shares of wind and PV
Future Electricity Markets: key pillars with high shares of wind and PVLeonardo ENERGY
 
Implement Structure for an Accessible Experience on the Web_Techshare India 2014
Implement Structure for an Accessible Experience on the Web_Techshare India 2014Implement Structure for an Accessible Experience on the Web_Techshare India 2014
Implement Structure for an Accessible Experience on the Web_Techshare India 2014BarrierBreak
 

Viewers also liked (14)

( 1 )تابع المتتابعات الحسابية
( 1 )تابع المتتابعات الحسابية( 1 )تابع المتتابعات الحسابية
( 1 )تابع المتتابعات الحسابية
 
Definición clasificación de blogs
Definición clasificación de blogsDefinición clasificación de blogs
Definición clasificación de blogs
 
Business models for effective market update of EE services
Business models for effective market update of EE servicesBusiness models for effective market update of EE services
Business models for effective market update of EE services
 
Fundraising-science-to-stewardship
Fundraising-science-to-stewardshipFundraising-science-to-stewardship
Fundraising-science-to-stewardship
 
Brais marina jose jonatan
Brais marina jose jonatanBrais marina jose jonatan
Brais marina jose jonatan
 
Vipin Kumar dip.chemical
Vipin Kumar dip.chemicalVipin Kumar dip.chemical
Vipin Kumar dip.chemical
 
The IEA Energy Efficiency Market report - What it means for DSM
The IEA Energy Efficiency Market report - What it means for DSMThe IEA Energy Efficiency Market report - What it means for DSM
The IEA Energy Efficiency Market report - What it means for DSM
 
Crisis de candidatos Columna Semanal del Diputado Waldo Fernandez
Crisis de candidatos Columna Semanal del Diputado Waldo FernandezCrisis de candidatos Columna Semanal del Diputado Waldo Fernandez
Crisis de candidatos Columna Semanal del Diputado Waldo Fernandez
 
Congelador Smeg CV275PNF
Congelador Smeg CV275PNFCongelador Smeg CV275PNF
Congelador Smeg CV275PNF
 
Fauna Marina
Fauna MarinaFauna Marina
Fauna Marina
 
Lista cotejo portafolio_digital aleja
Lista cotejo portafolio_digital alejaLista cotejo portafolio_digital aleja
Lista cotejo portafolio_digital aleja
 
Future Electricity Markets: key pillars with high shares of wind and PV
Future Electricity Markets: key pillars with high shares of wind and PVFuture Electricity Markets: key pillars with high shares of wind and PV
Future Electricity Markets: key pillars with high shares of wind and PV
 
Implement Structure for an Accessible Experience on the Web_Techshare India 2014
Implement Structure for an Accessible Experience on the Web_Techshare India 2014Implement Structure for an Accessible Experience on the Web_Techshare India 2014
Implement Structure for an Accessible Experience on the Web_Techshare India 2014
 
Bullyingg
BullyinggBullyingg
Bullyingg
 

Similar to Pcpt1

Forensic Toolkit Analysis Of A Windows 98 Virtual
Forensic Toolkit Analysis Of A Windows 98 VirtualForensic Toolkit Analysis Of A Windows 98 Virtual
Forensic Toolkit Analysis Of A Windows 98 VirtualBrjco
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTPMykhailo Kolesnyk
 
Introduction to Linked Data Platform (LDP)
Introduction to Linked Data Platform (LDP)Introduction to Linked Data Platform (LDP)
Introduction to Linked Data Platform (LDP)Hector Correa
 
Unit 1 introduction to web programming
Unit 1 introduction to web programmingUnit 1 introduction to web programming
Unit 1 introduction to web programmingzahid7578
 
Lecture 1 Introduction to Web Development.pptx
Lecture 1 Introduction to Web Development.pptxLecture 1 Introduction to Web Development.pptx
Lecture 1 Introduction to Web Development.pptxKevi20
 
Introduction to web technology and it's implementation
Introduction to web technology and it's implementationIntroduction to web technology and it's implementation
Introduction to web technology and it's implementationSureshSingh142
 
How to connect file server
How to connect file serverHow to connect file server
How to connect file serverKichiemon Adachi
 
Ingestion file copy using apex
Ingestion   file copy using apexIngestion   file copy using apex
Ingestion file copy using apexApache Apex
 
Downloading a Billion Files in Python
Downloading a Billion Files in PythonDownloading a Billion Files in Python
Downloading a Billion Files in PythonJames Saryerwinnie
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Chapter 6 Downloading & Storing Information
Chapter 6 Downloading & Storing InformationChapter 6 Downloading & Storing Information
Chapter 6 Downloading & Storing InformationPatty Ramsey
 
some fundamental topics to remember when starting with HTML
some fundamental topics to remember when starting with HTMLsome fundamental topics to remember when starting with HTML
some fundamental topics to remember when starting with HTMLfaiz324545
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009Cathie101
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009Cathie101
 

Similar to Pcpt1 (20)

Webtechnologies
Webtechnologies Webtechnologies
Webtechnologies
 
Unit 2.1 Part 4
Unit 2.1 Part 4Unit 2.1 Part 4
Unit 2.1 Part 4
 
Forensic Toolkit Analysis Of A Windows 98 Virtual
Forensic Toolkit Analysis Of A Windows 98 VirtualForensic Toolkit Analysis Of A Windows 98 Virtual
Forensic Toolkit Analysis Of A Windows 98 Virtual
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Web engineering
Web engineeringWeb engineering
Web engineering
 
Introduction to Linked Data Platform (LDP)
Introduction to Linked Data Platform (LDP)Introduction to Linked Data Platform (LDP)
Introduction to Linked Data Platform (LDP)
 
INLS461_day14a.ppt
INLS461_day14a.pptINLS461_day14a.ppt
INLS461_day14a.ppt
 
Unit 1 introduction to web programming
Unit 1 introduction to web programmingUnit 1 introduction to web programming
Unit 1 introduction to web programming
 
Lecture 1 Introduction to Web Development.pptx
Lecture 1 Introduction to Web Development.pptxLecture 1 Introduction to Web Development.pptx
Lecture 1 Introduction to Web Development.pptx
 
Introduction to web technology and it's implementation
Introduction to web technology and it's implementationIntroduction to web technology and it's implementation
Introduction to web technology and it's implementation
 
Servlet & jsp
Servlet  &  jspServlet  &  jsp
Servlet & jsp
 
How to connect file server
How to connect file serverHow to connect file server
How to connect file server
 
Ingestion file copy using apex
Ingestion   file copy using apexIngestion   file copy using apex
Ingestion file copy using apex
 
Downloading a Billion Files in Python
Downloading a Billion Files in PythonDownloading a Billion Files in Python
Downloading a Billion Files in Python
 
14(1) 005
14(1) 00514(1) 005
14(1) 005
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Chapter 6 Downloading & Storing Information
Chapter 6 Downloading & Storing InformationChapter 6 Downloading & Storing Information
Chapter 6 Downloading & Storing Information
 
some fundamental topics to remember when starting with HTML
some fundamental topics to remember when starting with HTMLsome fundamental topics to remember when starting with HTML
some fundamental topics to remember when starting with HTML
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009
 

Recently uploaded

VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service SaharanpurVIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service SaharanpurSuhani Kapoor
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样qaffana
 
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberMs Riya
 
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)kojalkojal131
 
FULL ENJOY - 8264348440 Call Girls in Hauz Khas | Delhi
FULL ENJOY - 8264348440 Call Girls in Hauz Khas | DelhiFULL ENJOY - 8264348440 Call Girls in Hauz Khas | Delhi
FULL ENJOY - 8264348440 Call Girls in Hauz Khas | Delhisoniya singh
 
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...Pooja Nehwal
 
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一ga6c6bdl
 
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...Pooja Nehwal
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...nagunakhan
 
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...Pooja Nehwal
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Pooja Nehwal
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gayasrsj9000
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一zul5vf0pq
 
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...nagunakhan
 
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...anilsa9823
 
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一ga6c6bdl
 
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...Suhani Kapoor
 
Call Girls Dubai Slut Wife O525547819 Call Girls Dubai Gaped
Call Girls Dubai Slut Wife O525547819 Call Girls Dubai GapedCall Girls Dubai Slut Wife O525547819 Call Girls Dubai Gaped
Call Girls Dubai Slut Wife O525547819 Call Girls Dubai Gapedkojalkojal131
 

Recently uploaded (20)

VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service SaharanpurVIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
VIP Call Girl Saharanpur Aashi 8250192130 Independent Escort Service Saharanpur
 
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
哪里办理美国宾夕法尼亚州立大学毕业证(本硕)psu成绩单原版一模一样
 
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up NumberCall Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
Call Girls Delhi {Rs-10000 Laxmi Nagar] 9711199012 Whats Up Number
 
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
(=Towel) Dubai Call Girls O525547819 Call Girls In Dubai (Fav0r)
 
FULL ENJOY - 8264348440 Call Girls in Hauz Khas | Delhi
FULL ENJOY - 8264348440 Call Girls in Hauz Khas | DelhiFULL ENJOY - 8264348440 Call Girls in Hauz Khas | Delhi
FULL ENJOY - 8264348440 Call Girls in Hauz Khas | Delhi
 
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
9892124323 Pooja Nehwal Call Girls Services Call Girls service in Santacruz A...
 
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
定制宾州州立大学毕业证(PSU毕业证) 成绩单留信学历认证原版一比一
 
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
9892124323, Call Girl in Juhu Call Girls Services (Rate ₹8.5K) 24×7 with Hote...
 
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls KolkataCall Girls Service Kolkata Aishwarya 🤌  8250192130 🚀 Vip Call Girls Kolkata
Call Girls Service Kolkata Aishwarya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
 
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...9004554577, Get Adorable Call Girls service. Book call girls & escort service...
9004554577, Get Adorable Call Girls service. Book call girls & escort service...
 
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
Call Girls In Andheri East Call 9892124323 Book Hot And Sexy Girls,
 
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(PARI) Alandi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
 
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
Russian Escorts in lucknow 💗 9719455033 💥 Lovely Lasses: Radiant Beauties Shi...
 
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
Lucknow 💋 Call Girls Adil Nagar | ₹,9500 Pay Cash 8923113531 Free Home Delive...
 
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
如何办理(NUS毕业证书)新加坡国立大学毕业证成绩单留信学历认证原版一比一
 
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
VIP Call Girls Kavuri Hills ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With ...
 
Call Girls Dubai Slut Wife O525547819 Call Girls Dubai Gaped
Call Girls Dubai Slut Wife O525547819 Call Girls Dubai GapedCall Girls Dubai Slut Wife O525547819 Call Girls Dubai Gaped
Call Girls Dubai Slut Wife O525547819 Call Girls Dubai Gaped
 

Pcpt1

  • 1. Fun Fun Project One 1 Fun Fun Project One Building Your Very Own Web Server
  • 2. Fun Fun Project One 2 What is a Web Server?  Program that understands the HTTP protocol and generates appropriate responses  Clients “connect” to the machine  Clients send a “request”  Server reads request, generates “response”  Client interprets response appropriately
  • 3. Fun Fun Project One 3 A Simplified Web Server  Client asks for file  Server finds appropriate file  Server sends back a response header followed by the requested file’s data  Server closes connection
  • 4. Fun Fun Project One 4 What Does “Connect” Mean?  For all practical purposes, it looks like there’s data available via a file descriptor  Stream of bytes  Can be treated like any other file descriptor  Not a FILE * (like stdio, stderr)  Must use read() and write() system calls
  • 5. Fun Fun Project One 5 How Do You Identify Machines  Domain names/IP address and ports  http://www.cs.princeton.edu implies a machine named www.cs.princeton.edu and a default port of 80  http://127.0.0.1:8080/index.html  Refers to local box (127.0.0.1 is me)  Port # is 8080 (used for this project)  File is named index.html
  • 6. Fun Fun Project One 6 How Do You Identify Files?  File name is specified in Request Message  Server maps that name to a real file  Mapping can be done in whichever way server wants  For example, /~vivek/index.html is actually /n/fs/fac/vivek/public_html/index.html  In your web server, you can choose your own
  • 7. Fun Fun Project One 7 What’s In A Request Message? GET /index.html HTTP/1.0rn Connection: Keep-Alivern User-Agent: Mozilla/4.72 [en] (X11..)rn Host: 127.0.0.1:31415rn Accept: image/gif, image/jpeg, */*rn Accept-Encoding: gziprn Accept-Language: enrn Accept-Charset: iso-8859-1,*,utf-8rn rn
  • 8. Fun Fun Project One 8 What Do You Care About? GET /index.html HTTP/1.0 In particular, just index.html Assume “/” means “/index.html”
  • 9. Fun Fun Project One 9 What Could They Want?  An honest-to-goodness file (me.jpg)  An indirect request for such a file (such as “/” meaning index.html)  An implied directory with index (/home/vivek instead of /home/vivek/)  Just a directory listing  A query (we don’t care about these)  An invalid/nonexistent file
  • 10. Fun Fun Project One 10 What’s In A Response Message? HTTP/1.0 200 OKrn Date: blah-blah-blahrn Server: blah-blah-blahrn Content-Type: importantrn Content-Length: 12345rn Last-Modified: blah-blah-blahrn rn Raw data
  • 11. Fun Fun Project One 11 What’s a Minimal Response? HTTP/1.0 200 OKrn Content-Type: stuffrn rn Data HTTP/1.0 302 Movedrn Location: newurlrn rn HTTP/1.0 404 Not Foundrn rn But also Connection: closern Content-Length: yyyrn
  • 12. Fun Fun Project One 12 Response when…  File exists? Send it  Directory without “/” suffix? Redirect  Directory with index.html? Send it  Directory with no index.html? List it  For each list entry, add “/” if needed  Failure(Not Found)? Send 404  Bad Request? Send 400
  • 13. Fun Fun Project One 13 How to Test Your Server?  Use a browser(Netscape/IE)  Use “wget”  Support HTTP protocol  http://www.gnu.org/manual/wget  create directory hierarchy for retrieving  Include some big images
  • 14. Fun Fun Project One 14 More Test Cases  What if Request Message is not send/received in one packet…  The server must read all the Request Messages before it gives any response message  Remember the double carriage return and line feed?  Your web server must consider this!  I’ll distribute more test programs later on, check http://www.cs.princeton.edu/~yongwang/cos318
  • 15. Fun Fun Project One 15 What is Content-Type? text/html image/gif image/jpeg (Other types not needed for project 1.)
  • 16. Fun Fun Project One 16 Need more info? HTTP 1.1 Specification – RFC2068 HTTP 1.0 – RFC 1945 man pages man man man –k blah read( ), write( ), open( ), close( )
  • 17. Fun Fun Project One 17 Why open instead of fopen?  Compare fopen, fread, etc., with open, read, etc  We’re dealing with functions closer to the OS – easier to use in some cases
  • 18. Fun Fun Project One 18 What’s a File Descriptor?  Sort of like a FILE *  It’s an integer provided by OS  Used to represent a stream of bytes  Can represent file or network connection  Behavior is slightly different  Especially when reading/writing network
  • 19. Fun Fun Project One 19 General Steps Setup, and then  Get next connection  If file, read from disk  If directory, generate listing  Send all to client  Close connection, wait for next one(nonpersistent connection)
  • 20. Fun Fun Project One 20 What Am I Given?  Setup function  Makes server available for connections  Accept function  Gets a connection from a client  File type function  Tells you what kind of file, if it exists  Tells you how many bytes if a regular file  Directory listing functions  Gives you the file names one at a time
  • 21. Fun Fun Project One 21 Help! I’m Lost!  Don’t know HTML?  Use Netscape composer to see what to do  View page source for various pages  Do “telnet www.domain.com 80” and issue the GET manually (need to add “Host: www.domain.com” header)  Ask
  • 22. Fun Fun Project One 22 Why Are We Doing This?  Infrastructure for future projects  Some OS/Networking interaction  It’s fun, and not too bad
  • 23. Fun Fun Project One 23 Wrap Up  Thanks!  Q&A session next week!  Office Hour: Wed 4:30-5:30