Slashdot Mirror


phpstack - A TCP/IP Stack and Web Server in PHP

Adam Dunkels writes "Following the trend of writing 'inappropriate' programs in the PHP scripting language, I have written a small TCP/IP stack and a web server entirely in PHP. It is extremely stripped down: the IP stack only implements the most basic functionality required for running the web server and the web server cannot handle pages larger than 1.5k. Nevertheless, the stack is able to support an unlimited number of simultaneous TCP connections and the web server has support for PHP scripting. A live demonstration server is up and running the phpstack software."

14 of 295 comments (clear)

  1. Unlimited connections, really? by zeux · · Score: 5, Funny

    The server only allows very small HTML pages and pictures, but it is able to support an unlimited amount of simultaneous connections.

    You shouldn't have said that here. We are about to brute test this 'unlimited amount of simultaneous connections' thing.

    1. Re:Unlimited connections, really? by ernstp · · Score: 5, Funny

      Must Click Link To Experimental Webserver, Must Click...

    2. Re:Unlimited connections, really? by requim · · Score: 5, Funny
      You shouldn't have said that here. We are about to brute test this 'unlimited amount of simultaneous connections' thing.

      I believe that was his point (Why not have slashdot do your load testing..)
  2. Alright. by whiteranger99x · · Score: 5, Funny

    Ok everyone, get it out of your systems already! :P

    "whoa 2 comments and it's already slashdotted"
    "whoa dude, shouldn't have let slashdot post your server!"
    "Imagine a beowulf cluster of these guys"

    And i'm sure you can figure out more Slashdotisms people *smirks*

    Seems pretty cool at any rate

    --
    Join the TWIT army now!
  3. ouch... by zoloto · · Score: 5, Funny

    unlimited number of simultaneous TCP connections

    To the tune of Queen:
    Another one bytes the dust!

    1. Re:ouch... by Sir_Real · · Score: 5, Funny

      Well... You really were asking for it...

      With apologies to the late F.M.

      Php is a scripting language
      not a layer three network stack
      Ain't no way your server won't break
      Unless you're sitting in a SONET node rack

      Are you crazy? Are you certified
      Your server is a molten heap
      Through the floor the slag still drips
      to the sound of the beep

      Chorus:
      Another one bytes the dust
      Another one bytes the dust
      And another one gone, and another one gone
      Another one bytes the dust
      Hey, I'm gonna slashdot you
      Another one bytes the dust

      How long till my router cacks
      after a weekend slashdot bitch smack
      I invested everything that I had
      even wrote a custom ip stack

      Are you crazy? Are you certified
      Your server is a molten heap
      Through the floor the slag still drips
      to the sound of the beep

      chorus

      There are plenty of ways you can hurt a host
      and bring it to its knees
      you can heat em
      you can drop em
      you can install bad ram
      and even try using Windows ME

      But you're batshit, yes out of your tree
      If you think your isp won't freak
      Through the floor your server melts
      To the sound of the beep

      chorus

  4. Due to the anticipation of the /. effect . . . by dgrgich · · Score: 5, Informative

    Here's a screenshot of the phpserver results. Pretty cool stuff.

  5. Re:Ouch by jx100 · · Score: 5, Funny

    "You are visitor number 1339"

    dammit, if I was only 2 users earlier...

  6. Re:That is a VERY limited system.... by igrp · · Score: 5, Insightful
    Hmm... To quote the server's main page:

    Welcome to the phpstack demo server! phpstack is a small TCP/IP stack and web server written in PHP. It is a quick and dirty proof-of-concept hack and shouldn't be taken too seriously.

    Well, it clearly says it's a PoC hack so why not cut this author some slack? To be perfectly honest, I think this is rather impressive in more than one way. Sure, this isn't exactly a novel idea but that wasn't the point. It clearly is a show of flexibility. Php wasn't designed with these kinds of applications in mind, yet it seems to handle this kind of stuff impressingly well.

    Also, it testifies to the fact that thinking outside the box is a good thing. I mean, come on, what would you rather see yet another mail client or some cool project that makes you go "hmm, how come I never thought of this"?

  7. Re:That is a VERY limited system.... by Fearless+Freep · · Score: 5, Insightful

    Yeah, I wrote a quick and dirty proof of concept distributed object client/server in Python in about two hours, but I wouldn't post it to slashdot. Quick and dirty proofs of concepts are what progreammers do every day...so what?

  8. Re:I don't get it, really I don't by madstork2000 · · Score: 5, Informative

    PHP does not depend on a webserver to run. It can be executed standalone just fine. I use it that way as a PERL replacement. No need for flame wars, I do still use PERL , the PHP stuff is for "backend" scripts on my webservers that share some common custom PHP libraries I have written as part of web applications, in so doing I eliminated the need to reimplement a lot of logic in PERL...Anyway that was off topic, the point is PHP does NOT need a webserver to run.

    MS2k

  9. Different window? by kendallemm · · Score: 5, Funny
    Just let it load in a different window while you read the rest of the headlines.

    This is slashdot. I think you meant "different tab" ;)

    KB
  10. From the author by dunkels · · Score: 5, Informative

    I am the author of this and I must point out that the phpstack server is actually still running after over two hours of slashdotting! It is extremely slow, however, because of the insane amount of IP packets that have to traverse the 115200 bps serial line that connects the server with the rest of the world. The front page of the server currently reports that it has served 13157 visitors.

    A lot of people that comment here focus solely on the web server part of this software and completely miss the novel part in this: the TCP/IP stack. Writing a simple web server is dead easy. To the best of my knowledge, however, nobody has been stupid enough to write a TCP/IP stack in PHP before :-). The web server running on top of the stack is really simple and can be seen as the equivalent of the "netcat" web server someone suggested.

    The TCP/IP stack is intensionally extremely simplified (or "half-baked", if you wish) and tailored to the specific needs of the simple web server. Someone implied that the reason for the simplifications was that I maybe hadn't "figured out" how to handle fragmented packets. Well, it does not have to do with packet fragmentation (IP fragmentation is not that much of an issue today), but with the TCP receiver not trying to put together incoming TCP segments into a stream. Interested people could take a look at my uIP or lwIP TCP/IP stacks to see how to solve these problems in the general case. I have also written a paper that discuss issues with reducing TCP and IP in more detail.

    Of course, there are also the standard "this guy should get a life" comments. I always find it amusing to see such comments being posted only 10 minutes after the article hit the Slashdot front page, on a Saturday. I'm not the only one in need of a life, it seems :-)

    Finally, all of this is just a quick hack made solely for fun (and in part to learn more about PHP). I submitted it to Slashdot simply because I enjoy seeing articles like this myself. From the insane amount of traffic to my demo server, it seems that quite a lot of other people find it interesting as well :-)

  11. Re:PSHTTPD - PostScript webserver by InfiniteZero · · Score: 5, Funny

    What would be REALLY impressive is a webserver written in HTML.