help with web interface
Terry Swanborough (61) 152 posts |
Hi I have a data logging type program running under RISC OS I would like if possible to send and receive simple data between my program The most versatile interface I imagine would web based? . as this I would like to be able to do simple tasks like:- Password protected access I have quite a lot of programming experience with RISC OS but very little Anyway I am looking for some guidance before I start delving into solutions, Can RISC OS do At the moment my program is a single tasking graphic program but it could be made to multi task. Regards Terry |
Colin (478) 2433 posts |
What you want is not difficult the most difficult bit is understanding sockets. Basically you need to choose a port write a server to accept incoming connections on that port and parse commands from the client and act on them. You then need to write the client. The ‘write a server’ ‘write a client’ but sounds complicated but it isn’t as bad as it sounds and each can probably be done in a few of screenfuls of code. The terminology is scarier than the implimentation. When connected to the server the client would send an authentication command to verify user and disable all other commands until authentication succeeds – the authentication is nothing to do with sockets its a protocol that you make up. The protocol – that you make up – may go something like Client sends ‘auth user password’ ‘readtime’ would fail if ‘auth’ failed The numbers would be error codes – don’t use them if you don’t want them You can simplify the multitasking part by running in a taskwindow What language do you want to write this in? |
Terry Swanborough (61) 152 posts |
Hi It can be in C or BASIC I don’t mind, what I would like is something Regards Terry |
Colin (478) 2433 posts |
That’s not something I’ve tried. I’ll leave any further suggestions to CGI experts |
Martin Avison (27) 1494 posts |
You need to clarify ‘between my program’ and what else?
I would suspect that it would need to be multi-tasking, as it will (presumably) need to be do the logging and communicate at the ‘same’ (human) time? |
Terry Swanborough (61) 152 posts |
Hi The communication would be between my program and Another web page could be used to set up configuration data The program can be changed to multi task that is not a problem Regards Terry |
Rick Murray (539) 13840 posts |
Try looking in NAT or port forwarding in your router’s configuration. Open the port (can be 80 for http), point it at your machine. Everything connecting to your router’s public IP will be pushed to your server. You can get a domain name alias from NoIP.com. Useful if your ADSL router can automatically sync your public address with NoIP. Orange Livebox can. I know, mine does. Be very very aware that you will get hundreds of connections pretending to be the BaiduBot and often making really weird requests. It may be better to rely upon WebJames to be the server (mine has been coping with it since my last reboot 42 days ago). Don’t take my word for it. Fire up WebJames, put in a dummy index and delete the default CGI scripts, open a port, give it a few days, then check your logs. Web2.0 is not a friendly place. Work with that knowledge from the outset. |
John Sandgrounder (1650) 574 posts |
Hi Terry, I see no reason why RISCOS can not do what you are looking for. The latest formal build is a very stable and versatile system (client or server). Writing a web interface is not as scary as it sounds and Webjames will let you write CGI scripts in Basic. Don’t delete the default CGI scripts. Modify copies of them to learn how they work. I use !Wget on the Client side of things. It is also very easy to drive from RISCOS (and many other systems). Sending messages/data from one RiscOS system to another is very simple using the combination of !Wget on a client to !Webjames on a server. The issue about using a public IP address from within a local network depends on how good your router is. Many will do it fine – Search for IP loopback. (I use Draytek) The number of rogue connections you will get depends on many factors (including how good your ISP is). I have servers running Apache on Linux and Webjames on RISCOS. I get very few rogue connections on tho port 80 apache and none on Webjames with higher port numbers on a number of RasPi systems. In any case, most hackers would not know what to do with a RiscOS/Webjames system so will just go elsewhere. |
Rick Murray (539) 13840 posts |
This thread got me to thinking about writing a simple server (in C). Something I’d been meaning to do for a long time. http://www.heyrick.co.uk/blog/index.php?diary=20160104
A self-built RISC OS from May(ish) sources (IIRC!) is running happily after 42 days. I’m sure it can do more, but as a developer I reboot from time to time. I’m not doing much low level development work because I’m just wondering how long everything will keep running… Hmm… Has anybody recorded the longest known uptime of a RISC OS machine?
That’s fair enough, but don’t put the server on-line with any of the default things in place.
Advanced routers, custom (non-ISP) ones, and anything with the likes of OpenWRT perhaps. I’m not so sure a bog standard ISP provided router will do fancy stuff like that.
I think it comes down to the criteria of how the ISP implements the blocking. Because there is a trade-off between stopping rubbish and blocking too much. I remember reading that one ISP (American?) blocks the entirety of China. It appears from my examinations that the dross comes from hijacked machines. I don’t think I’ve been poked by the same IP address twice (and I’ve had 593 attempts since Saturday evening). The addresses are mostly China, but I’ve seen Israel, Turkey, Spain, and Moldova. There are probably many more but I just pick addresses at random to look up, most of them get dropped on the floor as life is too short to care where ~600 machines are located.
I wonder how your ISP blocks, and if it inconveniences legitimate visitors?
True, they will. With my server (on a telnet port), they connect and sit idle for a minute until the server times them out and kicks them off. I think things would be more interesting if the server looked like a Unix login prompt. But it doesn’t. However it is useful to be aware of this stuff, because the “hackers” (in quotes, as it is a script, not anything real) are stupid and will keep connecting for as long as there is a reply. My server will notice quick-fire connections and will blacklist that IP address. After a set number of reconnects, it will simply abort the connection as soon as it is noticed. This stops the bot. If it gets a reply it will keep on going for maybe as many as 40 or 50 attempts. Slam the door on it, it goes away. It isn’t a big deal. It doesn’t harm anything, and it is useful for stress testing the server. ~150 connections a day is…about 149 more than I’d expect otherwise…so I’m not bothered if the botnet wants to poke the server, it can cope. |
Terry Swanborough (61) 152 posts |
Hi Thanks for the replies I think I will continue with Webjames at the moment. Anyway back to the books Regards |
Rick Murray (539) 13840 posts |
Just looked at my stats. It looks like I’ve had about 360 connection attempts today. Must be a rainy day in Shengzen… |
Michael Emerton (483) 136 posts |
Well no recorded time, but I am aware of at least 10 A3/4xx Class machines which have only been powered down a handful of times, with the odd update to the software. Otherwise they have been on and working since the day they were installed RISC OS 3.11. |
Chris Evans (457) 1614 posts |
Michael: I’m intrigued, what are they doing? |
Michael Emerton (483) 136 posts |
Chris: Testing! The actual machines started off with Arthur and then RISC OS 2 then 3… I need to get my dad to write his story to do a meeting at ROUGOL :) |