GithubHelp home page GithubHelp logo

nirvananimbusa / threaded-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jyn514/threaded-server

0.0 1.0 1.0 291 KB

A stupid simple server with threading

License: BSD 3-Clause "New" or "Revised" License

Makefile 4.89% C++ 2.46% C 81.36% Shell 10.34% Dockerfile 0.95%

threaded-server's Introduction

threaded-server

Build Status

Servers static files and prevents path traversal attacks. Will probably crash if you try anything fancy.

However, it handles requests at about 10 msec/response, which is comparable to Nginx. Try ab -n 1000 -c 100 localhost:8080/ for a comparison.

Usage

$ ./main -h
usage: ./main [<port>] [<host>]

Compiling

Dependencies

  • make (or gmake on Mac/BSD)
  • a C compiler. clang is the default, change CC=gcc in the makefile if you don't want to install it.
  • libmagic (brew install libmagic on Mac, should be preinstalled on Linux/BSD)

Testing

Dependencies

Running Tests

make test

Optional

valgrind --leak-check=full build/main 8080

Run a few queries and see if there's any memory leaks.

But Why?

I'm taking networking and operating systems courses where we don't write any code. I thought it would be nice to get hands-on in system internals.

Licensing

This project is licensed under the BSD 3-Clause license. See LICENSE.txt for details.

TODO

  • Figure out why -fsanitize=thread thinks my interrupt handler isn't safe
  • Check what happens if we run into the thread limit (currently, we spawn a thread for every request no matter how many threads we already have)
  • Figure out why sleep(10) in handle_request adds a response time of 18 seconds
  • Logging (?)
  • Dynamic pages (??)
  • HTTP/2.0 (???)

threaded-server's People

Contributors

jyn514 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.