An event when there is data to read on a socket?
Rick Murray (539) 13840 posts |
Not really. Remove the stuff about the C runtime, all the rest still applies.
Hehe, anybody that wanted anything done sensibly in the ’80s used assembler.
I’m not the world’s greatest when it comes to assembler. I probably rank as “immature schoolgirl” compared to Jeffrey, Sophie, etc. What I can tell you, though, is that debugging assembler is a whole different story. Given that most of the points raised will still apply, you might as well stick with C.
Then that’s okay. The Event is just telling you something happened. Schedule a CallBack, then you can recv() and write at your leisure.
How do you mean? To be called at regular intervals? OS_CallAfter for one-offs, and OS_CallEvery for a repeated call (if you want 1cs calls, you will need to hook into TickerV). Note, however, that CallAfter/CallEvery have restrictions on use. Yup, you guessed it. :-)
Word of advice – don’t. Unless you are bored with your surroundings and hate the people you are with, enjoy your holiday time and leave this stuff until holiday is done with. Holidays are special and should be considered sacrosanct.
You’re welcome. That was my second try, since I pressed a key while trying not to drop a big cheesy bit of pizza and Firefox went back a page and threw away my text. Oh well, the second version was better anyhow. ;-)
Sounds like you’re trying to do too much in the event handler. Just note that “socket XXX needs attention”. Defer everything else until RISC OS prods you. Then, so long as the socket descriptor is valid, there shouldn’t be a problem. |
Colin (478) 2433 posts |
If you feel the need to use the Internet event to inform your application of internet events then the event handler just needs to set set a word that you register with it to non zero and you pass that block of memory to wimp poll and use the wimp poll non zero wimp event. Doing the data transfer in the module won’t make the transfer any faster and application space gives you control of how often to poll if data transfer is too slow or too fast – too fast stalls the wimp on large transfers, too slow and you can add a wimp poll while you wait. You could register more than a 4 byte pollword with the module and have the module fill in the other fields to the internet event data when the handler sets the pollword to non zero – not much point though. On receipt of a pollword non zero wimp event you can do what you need to do and multitask with the occasional wimp poll. Once you are transferring data you can ignore the internet event – it’s only really useful for a listening socket to notify connections. But you can get away without it. Personally I wouldn’t use a module if I didn’t have to. |
Malcolm Hussain-Gambles (1596) 811 posts |
I currently do the data transfer on the application side, I’ve found putting that level of complexity in the application is making my programs too bloated. Using a module allows a cleaner abstraction. I’m using the module to do the whole lot, the DNS lookup and handle the download/streaming and then send a wimp event. My hope is to allow “plugins” which will be non-module wimp based to decode the various protocols and can hook into the module to extend and control it. |
Colin (478) 2433 posts |
Looks complicated, enjoy. |
Malcolm Hussain-Gambles (1596) 811 posts |
I’ve managed to get more than an hour to look at programming again ;-) I’ve done a search in the header files and these don’t seem to exist. |
Bill Antonia (2466) 130 posts |
I use a couple of modules I wrote back in 1998 which I have recently dusted off and converted for 32bit addressing. One is for managing Pollwords the other for managing AsyncSockets. What you have to do is register your task with the Pollword module and then pass the returned address to the AsyncSocket module along with the socket descriptor. The AsyncSocket module takes care of enabling and disabling the Internet event so you don’t have to do this in your own tasks. When an Internet event happens the AsyncSocket module modifies the tasks Pollword which in turn the task is switched in within the Wimp Poll loop. The originals were written in assembler and have been updated but recently I have been experimenting writing the AsyncSocket module in C, still works but a bug stops the module being killed after it has been used, the assembler version works. If you want copies of these then let me know. |
Malcolm Hussain-Gambles (1596) 811 posts |
@Bill, not sure you’re still around – but if you are I would love a copy of the modules. |
Bill Antonia (2466) 130 posts |
Yes, still around. I’ll upload the code and modules to my website for download, I’ll post the link on the forum when it’s there. Here is the link: You register your wimp applications task handle with the Pollword module then you pass the pollword address returned to the AsyncSocket module along with the socket descriptor. Finally set up your mask and enter the poll loop. This enables you to use pollwords without having to make your wimp task a module task and still have the pollword location in a static place all the time, therefore not being paged out. When an Internet event happens the associated tasks pollword is modified and therefore your task is polled and gains control to service the event. It’s strange Acorn never wrote a module to manage pollwords and built it into RiscOS in the first place, I’m sure they would have done a better job. The download is compatible with SparkFS, just remove the .zip extension. Note, not all of the daemons have been rewritten for the current C/C++ libraries, they used to use the UNIXLib. Check the configuration file inside !Inetd for the ones that currently work. By the way, the SWI numbers are registered for both modules so there should be no clashes with any you may write. |