Port 80 is the default HTTP port. What I was asking is how the browser can find the server if it is running through a port (5000) that is not default. Normally you would have to enter the address (71.63.4.228) followed by the port number (:5000) so you would have this as the address (71.63.4.228:5000). My router is set up to forward public port 5000 to private port 80. The spinneret is set up as follows
'Start the W5100 driver
W5100.StartINDIRECT(_WIZ_data0, _WIZ_addr0, _WIZ_addr1, _WIZ_cs, _WIZ_rd, _WIZ_wr, _WIZ_rst, _WIZ_sen)
MAC[0] := $00
MAC[1] := $08
MAC[2] := $DC
MAC[3] := $16
MAC[4] := $F0
MAC[5] := $10
'Subnet address to be assigned to W5100
Subnet[0] := 255
Subnet[1] := 255
Subnet[2] := 255
Subnet[3] := 0
'IP address to be assigned to W5100
IP[0] := 10
IP[1] := 0
IP[2] := 1
IP[3] := 2
'Gateway address of the system network
Gateway[0] := 10
Gateway[1] := 0
Gateway[2] := 1
Gateway[3] := 1
'Local socket
localSocket := 80
'Destination IP address - MUST BE SET TO THE SERVER TO CONNECT TO
destIP[0] := 0
destIP[1] := 0
destIP[2] := 0
destIP[3] := 0
destSocket := 80
My IP address is 71.63.4.228 or http://www.blueridgemountainresources.com sometimes everything loads sometimes nothing loads. If the page loads with a white background refresh it. On the photos page the photos never load. Also the server gets hung if you refresh the page before it finishes loading.
Oh and the files that get hung are images like on the photos page and video like the one on this link http://www.blueridgemountainresources.com/media/hslides/computer.mp4 This video is supposed to go in the player on the homepage but I removed it so the server would not hang.
You have a lot of IO going on. You can take a look at the log.txt file to get an idea what's of happening. Should be on the root if you loaded HttpServer.spin found on this forum thread.
I'm sure the Spinneret can serve up your site, it's just a matter of figuring out the problem and adjusting the code base.
I tried loading the code you had put on this thread but the server would not work at all. Can you tell me which files are required to use your new code?
I only added the two files that were updated to the zip archive. All the supporting files stayed the same and were not part of the zip archive. Be aware that the code is a bit raw. It still has a lot of debugging statements for a terminal application.
What does this mean?
I tried loading the code you had put on this thread but the server would not work at all.
Did you receive an error? If so what was the error? Try adding a blank log.txt file to the root.
When the server rebooted after loading the code the red light stayed lit and when I went to the web address of the spinneret the site would not load. Can you post the spin files you use so I can compare them to the ones I am using and try to find a solution.
Try adding an empty log.txt and favicon.ico to the root of the SD card. I did not check if log.txt exists before trying to open the file. I simply added the file so I could do some quick and dirty logging.
I tried the code you posted above but the server would not work. When the server restarted after loading the code it came up with status code 14 in the terminal. I don't know what this means but I still can't get your code to work with the server. Any suggestions? Thanks
It is shown in case that LISTEN commands are given to
Sn_CR at the SOCK_INIT status. The related socket will
operate as TCP Server mode, and become ESTABLISHED status
if connection request is normally received.
Which means that the web server is waiting for a request.
I still can't get your code to work with the server. Any suggestions?
I admit that my code is beta at best and was more of a "getting my feet wet" exercise. There is a bug in my GET and POST methods other than that I can generate dynamic content and linked files no problem. I don't know what happening on your end as the problem description is not very detailed. I 'd have to get your HTML files and drop them on my spinneret to see what you're talking about.
I'm in the middle of a rewrite. I'm not sure how long it will take. Spinneret time is directly proportional to my wife's tolerance. My advice... wait until I post the new code, grab other code, or roll your own.
I don't understand why the spinneret has to have the WriteResponseHeader section. Why does the spinneret have to know what type of file it is serving up? In other words when someone connects to the website why can't the spinneret just sent the files to the client? When someone connected to a web server I thought it just sent the requested files to them.
When someone connected to a web server I thought it just sent the requested files to them.
No, web transactions don't work that way. There is behind-the-scenes handshaking going on (on top of TCP) called the Hypertext Transfer Protocol (HTTP), which client requests and server responses must adhere to. The Spinneret's W5100 chip handles the TCP stuff, but it is up to the Propeller program to take care of HTTP requirements.
All web requests and responses require an HTTP header. (The nice thing about HTTP is that's it's entirely in human-readable ASCII form.) In the case of server responses, these tell the client what kind of data it's receiving, be it a webpage, an image, or a file. For example, the following would tell the client that the data make up a JPEG image:
Content-type: image/jpeg
In the best of circumstances, this "mime-type" supercedes any suffixes that may be appended to the file or page name. The header can also include information about whether or not the data should be cached (and, if so, for how long), whether it's sent encrypted or not, when it was last modified, and many other things.
The end of the header is signaled by one blank line, after which the actual content can begin.
On a normal web server running Mac OS X on Linux is the information like mime types held in the .htaccess file? Also how can normal web servers send any type of file to a client?
No, .htaccess is used to restrict who can access the resource folder in which the files exist.
All webservers ("normal" or otherwise) can send any type of file by prepending the necessary HTTP header that tells the client what kind of file it is.
So if I wanted the spinneret to be able to send any type of file, I could add all of the mime content types to the WriteResponseHeader section? (At least all of the mime content types that exist)
I have noticed a bug in the spin code but I can't find a solution. When I access a page of the website the page loads but the spinneret gets stuck in a loop where is says
I went back to the code I was using a while ago. The old code does not have a log.txt and the logging never worked before so I just did not implement into my old code. I don't know for sure if it is a bug but I guessed it was because it happens any time I load a page of the website that has not been loaded before.
Also the server does not always serve up all of the requested files/ files required for the page. these files include images and CSS files. Some times it serves up all of the files. Some times it doesn't. I have looked for a solution but have not found a problem.
I tried your new code. I found that the spinneret only loads the page once and then stops responding. It then must be reset. I looked in the log and it appears that the socket never gets reset after the first page load. Any ideas?
I'm afraid that the current code base is not going to work for your needs. Every resource request (scr="") in the html can cause the browser to open a new connection on the server as the page is rendered on the client. Phil identified the multiple connections issue and came up with a JavaScript solution that loads images after the HTML page loads. I'm not sure Phil's fix will be a convenient or workable option for your application.
I beleive your application will require all 4 WIZ5100 sockets and there's no guarantee that it will work. Then again, this is the latest information. The situation could change with more development.
I just downloaded the code provided by "Mike G", just a note: Javascript has a mime type of "application/javascript".
I noticed that in the HTTPServer.spin file it has "text/javascript", this will cause problems for some borwsers as they will refuse to parse the javascript files.
I suggest changing this.
I am working on a revised "WriteResponseHeader" function, but don't have a Spinneret.
Could someone please test it and let me know how it goes (once I post it).
I made the changes to the Response object. For others reading this, file extension and content-type are in parallel DAT tables related by index. The Response object creates a hash on start up that maps the extension to media type. If you add a content-type, make sure the extension lines up by index with the media type.
I'm returning application/octet-stream if the media type is not listed.
Comments
My IP address is 71.63.4.228 or http://www.blueridgemountainresources.com sometimes everything loads sometimes nothing loads. If the page loads with a white background refresh it. On the photos page the photos never load. Also the server gets hung if you refresh the page before it finishes loading.
I'm sure the Spinneret can serve up your site, it's just a matter of figuring out the problem and adjusting the code base.
What does this mean?
Did you receive an error? If so what was the error? Try adding a blank log.txt file to the root.
What changes have you made?
Source code:
http://www.agaverobotics.com/spinneret/source/
Which means that the web server is waiting for a request.
I admit that my code is beta at best and was more of a "getting my feet wet" exercise. There is a bug in my GET and POST methods other than that I can generate dynamic content and linked files no problem. I don't know what happening on your end as the problem description is not very detailed. I 'd have to get your HTML files and drop them on my spinneret to see what you're talking about.
I'm in the middle of a rewrite. I'm not sure how long it will take. Spinneret time is directly proportional to my wife's tolerance. My advice... wait until I post the new code, grab other code, or roll your own.
All web requests and responses require an HTTP header. (The nice thing about HTTP is that's it's entirely in human-readable ASCII form.) In the case of server responses, these tell the client what kind of data it's receiving, be it a webpage, an image, or a file. For example, the following would tell the client that the data make up a JPEG image:
In the best of circumstances, this "mime-type" supercedes any suffixes that may be appended to the file or page name. The header can also include information about whether or not the data should be cached (and, if so, for how long), whether it's sent encrypted or not, when it was last modified, and many other things.
The end of the header is signaled by one blank line, after which the actual content can begin.
-Phil
All webservers ("normal" or otherwise) can send any type of file by prepending the necessary HTTP header that tells the client what kind of file it is.
-Phil
This should help you to understand the HTTP protocol a little better.
http://www.w3.org/Protocols/rfc2616/rfc2616.html
What might be causing this to happen? While the spinneret is doing this it is unresponsive.
What page is being requested? Can you post the HTML? What's in the log.txt file?
A request(s) is made, but no data is in the rx buffer.
How did you get the code working? Are you using the latest code?
Also the server does not always serve up all of the requested files/ files required for the page. these files include images and CSS files. Some times it serves up all of the files. Some times it doesn't. I have looked for a solution but have not found a problem.
http://www.agaverobotics.com/spinneret/source/
Awesome! This does not include the HTTPServer.spin. Where is the most recent HTTPServer.spin
I beleive your application will require all 4 WIZ5100 sockets and there's no guarantee that it will work. Then again, this is the latest information. The situation could change with more development.
You could help with development?
This would mitigate the effects of the problem, but not solve the problem itself.
I noticed that in the HTTPServer.spin file it has "text/javascript", this will cause problems for some borwsers as they will refuse to parse the javascript files.
I suggest changing this.
I am working on a revised "WriteResponseHeader" function, but don't have a Spinneret.
Could someone please test it and let me know how it goes (once I post it).
So I scrapped my version.
Still needs the mime-type fixed for "js" and "ico" files though.
js = application/javascript
ico = image/x-icon
also, if the mime-type isn't in the list; "text/plain" should be returned.
I'm returning application/octet-stream if the media type is not listed.