Write a C program that accepts a port number as a command line argument, and starts...

60.1K

Verified Solution

Question

Programming

Write a C program that accepts a port number as a command lineargument, and starts an HTTP server. This server should constantlyaccept() connections, read requests of the form:
GET /path HTTP/1.1\r\n\r\n
read the file indicated by /path, and send it over the \"connect\"file descriptor returned by the call to accept().

Answer & Explanation Solved by verified expert
4.2 Ratings (543 Votes)
include include include include csapph include include define MAXCACHESIZE 1049000 define MAXOBJECTSIZE 102400 ifdef BIT32 typedef unsigned long long aint else typedef unsigned long aint endif static const char useragent UserAgent Mozilla50 X11 Linux i686 rv1923 Gecko20100423 Firefox363rn static const char acceptencoding AcceptEncoding gzip deflatern static const char accept0 Accept texthtmlapplicationxhtmlxmlapplicationxmlq09q08rn int proxyint fd int openclientfdsafechar hostname int port int parseurichar uri char hostname int port int readrequestriot rp char bufrequest char hostname int port char uri void threadvoid vargp void initial void clienterrorint fd char cause char errnum char shortmsg char longmsg semt mutex static int setnum linenum static void init static int loaddatachar tag char response static void storedatachar response char tag static void popusageint array int key int len struct cacheline int valid char tag char block struct cacheset struct cacheline line int usage struct cache    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students