Shop OBEX P1 Docs P2 Docs Learn Events
Google Code repository for open-source Spinneret Web Server firmware - Page 2 — Parallax Forums

Google Code repository for open-source Spinneret Web Server firmware

2»

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-07-10 18:57
    $17 does not mean that you have data in the buffer only an established connection from the peer. If you see a $17, $16, or $21 and no data keep reading. If you see an $18, $1A, $1B, $1C, or $1D the socket is trying to close and you need to handle accordingly. I think this is were folks are seeing lockups.
  • ChrisCantrellChrisCantrell Posts: 25
    edited 2011-07-10 19:01
    Thanks, Mike! That makes perfect sense. I'll do that in my own code. Someone with permission might fix the demo-server on the trunk of the shared code in SVN.
  • Mike GMike G Posts: 2,702
    edited 2011-07-10 19:07
    Seriously, take a look at my HTTP Server code. I implemented a state machine that monitors the status registers in a separate process. I've had no lock ups related to sockets in months. I can hit my Spinneret server with Apache Bench 40,000 requests and 4 concurrent users no problem.

    That's another issue with the current demo, it uses only one socket. It's fine if your web page does not contain images, JavaScript files, or CSS files. If you have a page with one image, your browser might try to open two sockets and timeout on the second request. It's worse with 2 images. I think this is another source of reported lockups.
  • ChrisCantrellChrisCantrell Posts: 25
    edited 2011-07-10 19:29
    These are all things the new-comer (like me) should know! If I could get commit access to the repository I would make comments in the demo noting places where the demo is limited. And I would note Mike's state-machine.

    I think the demo is a great starting point, but a tweak here and there (like the zero-length and watching for socket-closes) would be helpful. So would comments about multiple-sockets.

    Is the moderator of the SVN subscribed to this thread? Who should I ask to get commit permission?
  • Mike GMike G Posts: 2,702
    edited 2011-07-20 05:52
    Added the base code for my Multi-Socket Spinneret Web Server. on the repository. The W5100 driver has been updated to monitor all 4 socket status registers. I've been running the updated driver since 2/2011 and so far it works well.
  • ChrisCantrellChrisCantrell Posts: 25
    edited 2011-07-22 03:48
    I tweaked the demo-web-server a bit. I added a read-loop that waits for data and checks the connection status with each spin. I added some comments about the simplifying assumptions and trade-offs in the code. Mike, I made reference in the comments to your multi-socket state-machine. I used a simple java program to test premature disconnects and fragmented requests. The demo is much more resilient now.
  • ChrisCantrellChrisCantrell Posts: 25
    edited 2011-08-02 17:22
    The W5100_Indirect_Driver.spin driver on the trunk had a bug in it. The "InitSocketMem" function is a switch statement with 3 labeled cases ("1", "2", and "3") and a default case. But there were two "2" labels instead of a "2" and a "3". I have fixed the copy/paste error on the trunk.

    If anyone was trying to use memory template 3 (all 8K assigned to socket 0) you were actually getting template 0 (2K assigned to each of the 4 sockets). This would have caused you problems.
  • ChrisCantrellChrisCantrell Posts: 25
    edited 2011-08-02 17:56
    Check me here gang.

    There are a lot of calculations in the W5100_Indirect_Driver code that go like this:

    pcktstart := (_RX_base + (_socket * $0800)) + pcktoffset

    The 8K buffer memory (read or write) in the WIZNET can be broken up into different configurations. For instance, I could have 4K for socket 0 and 2K for sockets 1 and 2 and none for socket 3. The above calculation assumes that all buffers are 2K ($800). Unless you are using the default 2K/2K/2K/2K configuration then the code doesn't work. Is anyone using any other memory configuration? Am I missing something in the code?
  • william chanwilliam chan Posts: 1,326
    edited 2011-08-21 04:46
    How to download spin code from the google repository?
    Everytime I try, I get html code....
  • Mike GMike G Posts: 2,702
    edited 2011-08-21 12:02
    Right click and "save file as..."

    Click on a link then click the "View raw file" link.
  • william chanwilliam chan Posts: 1,326
    edited 2011-08-21 17:32
    Thanks, I got it now.

    How come the HTTPServer code does include the DHCP client that seems to work well?

    What happens if I set the MAC code different from the code on the sticker?
  • Mike GMike G Posts: 2,702
    edited 2011-08-21 19:27
    How come the HTTPServer code does include the DHCP client that seems to work well?
    No particular reason other than running out of time in the Spinneret contest. Feel free to add DHCP to HTTPServer.spin.
    What happens if I set the MAC code different from the code on the sticker?
    Nothing other than running the risk of having two identical hardware IDs on your network. Unlikely, but I have to ask why not just use the ID on the sticker?
  • william chanwilliam chan Posts: 1,326
    edited 2011-08-22 04:19
    Hi Mike,

    What is the use of port2? It doesn't seem to be listening.
    Is it possible to use port1 for index1.htm and port2 for index2.htm and use 2 listen sockets for each port?
    (so that we can serve 2 websites on one spinneret?)
  • ChrisCantrellChrisCantrell Posts: 25
    edited 2011-08-22 05:50
    The demo code on the trunk of SVN is just a basic how-to-open-and-manage-sockets example. It demonstrates the primitives for talking to the WIZnet chip. But it is not an example of a multi-threaded web-server. Mike G's code (also in SVN) demonstrates a full-blown multi-connection state-machine. Note that the WIZnet chip is NOT intended for heavy-duty server lifting. It has only four sockets, which are easily consumed by just one user at a modern browser.
  • william chanwilliam chan Posts: 1,326
    edited 2011-08-22 06:23
    Hi Chris,

    After testing the HTTPServer SVN code, I think spinneret can serve a typical average corporate website which does not use heavy graphics.
    Even though a user may use up all the 4 sockets, they are only busy for a very short time. ( less than 2 seconds? )
    An average corporate website gets only a few hits per minute.
  • Mike GMike G Posts: 2,702
    edited 2011-08-22 07:00
    What is the use of port2? It doesn't seem to be listening.
    You are right! port2 listens for remote server responses. More information can be found on the Spinneret tutorial site, http://spinneret.servebeer.com:5000/
    Is it possible to use port1 for index1.htm and port2 for index2.htm and use 2 listen sockets for each port?
    (so that we can serve 2 websites on one spinneret?)
    No because you would need a way to evaluate the header before it arrived. Use the host header to route traffic to the appropriate application directory. You'll find an @approot variable in HTTPServer which holds the application root directory. I'm only using one web application but there is no reason you can't dynamically assign the application root in the Request object.
    After testing the HTTPServer SVN code, I think spinneret can serve a typical average corporate website which does not use heavy graphics.
    Any request that opens more than 4 sockets can be a problem. If you think about it, that's the current request, CSS file, JavaSCript file, and one image. However, you can turn on caching...
    Even though a user may use up all the 4 sockets, they are only busy for a very short time. ( less than 2 seconds? )
    Socket open time is related to the length of data being returned.
    An average corporate website gets only a few hits per minute.
    I don't know about that. My experience is quite the opposite.

    Please start a new thread for HTTPServer questions.
  • zjaf05zjaf05 Posts: 3
    edited 2011-12-03 20:07
    Mike G, How can I access the tutorial site? Clicking on the menu gets nowhere
  • Mike GMike G Posts: 2,702
    edited 2011-12-04 05:36
    Welcome to the forum zjaf05

    I'm not sure what you are asking. Since this thread is about the Google Code Repository, I'm guessing you're having trouble downloading the code? If so, click the file you want to download. Then in the "File Info" box on the right, click the "View raw file" link.

    Otherwise the online tutorial is located at http://spinneret.servebeer.com:5000/. If the menu does not drop down, click the browser's refresh button.
  • laser-vectorlaser-vector Posts: 118
    edited 2013-04-18 12:00
    i see nothing but one pdf in the downloads section. am i looking in the wrong place or is it all gone?
Sign In or Register to comment.