1. Message-passing via local ports
- Posted by GreenEuphorian Feb 02, 2021
- 1108 views
Last year I posted a question about the potential in OE/Phix for implementing a message-passing framework and 'actor' objects (see https://openeuphoria.org/forum/134721.wc?last_id=134721#134721). Since I got a mixed response, I have been rethinking the question and I came to the conclusion that it's not really necessary to implement a message-passing framework as such (as outlined in the original post), i.e. running as one program. A microservices-type architecture may also be used instead, with each object running as an autonomous program, in its own thread. This approach would eliminate the need for an overarching unified framework (i.e. a single program) to manage and supervise the actor objects. Objects would pass messages to one other via local ports (localhost:portnumber).
I would like to get some feedback from you guys regarding the feasibility of this approach. I would be using Phix.
In particular, do you expect any difficulties with having different programs exchange messages via local ports?
Thanks a lot,
2. Re: Message-passing via local ports
- Posted by katsmeow Feb 02, 2021
- 1066 views
It's possible, several people have done it, between programs, between languages and operating systems, between computers on a lan, and across the internet. There's rudimentary win and nix "chat" programs that exchange "data" in the archives from many years ago. I submitted code to use socks connecting Eu to Mirc decades ago, both localhost and across the lan, and was roundly denounced.
If you are favorable to those "in charge", you will beome the deity of choice, else you will be ridiculed and forgotten. I don't even volunteer code any more (see irc.e , and the http.e-tasks-news.ex fiasco).
My "claim to fame" would be i hooked the type system to make sharing happen with only the one keyword. I used IPC, thinking it was faster, but i did no speed tests. I also was/am leery of the OS blocking on winsock calls in compiled OE, although this is not a problem running interpreted with tasks.e.
Good lucks to you.
Kat
3. Re: Message-passing via local ports
- Posted by petelomax Feb 02, 2021
- 1070 views
This stuff is all a bit beyond me, but since the original post I have added a rudimentary sockets lib to phix, not sure if it will be any help, or riddled with bugs...
Note that it is currently windows-only, but was written such that getting it to work on Linux should only require relatively minor tweaks, from someone who knows what they're doing.
4. Re: Message-passing via local ports
- Posted by katsmeow Feb 02, 2021
- 1044 views
In particular, do you expect any difficulties with having different programs exchange messages via local ports?
You can simulate events with tasks.e doing polling (The actual shared data var will be filled up transparently to the main program) : create some shared variable as a flag that says "data is here!", or maybe one that says "i just got x bytes of data!", let a task poll that variable. Because the variable is (or can be) shared in both directions, resetting it in the main program can change the state in the aux program. Handshaking. Else, cache number, or hdd filename. In sending and recieving large files to/from Mirc to/from anywhere else, i used winsock's buffers, the favorable side effect being effectively a task_yield, allowing other code to run.
Kat
5. Re: Message-passing via local ports
- Posted by GreenEuphorian Feb 02, 2021
- 1096 views
Thanks a lot, Kat & Pete. I will look into it.
6. Re: Message-passing via local ports
- Posted by katsmeow Feb 02, 2021
- 1018 views
I forgot and had to go way afk, just got back... the message format : i have been passing only flat data, that is: one-level sequences, integers, atom booleans. Passing a 0 (zero) might mess you up, if it's interpreted as a null terminator. There's various ways to deal with messages and error detection and correction, i think it's a whole science by itself : "How To Trick The OS Into Letting You Program It". There's libraries in the archives for some issues, such as flattening nested sequences and unflattening them.
Kat
7. Re: Message-passing via local ports
- Posted by jimcbrown (admin) Feb 07, 2021
- 988 views
It's possible, several people have done it, between programs, between languages and operating systems, between computers on a lan, and across the internet.
And in addition to OP, I'm another one who has done it.
There's rudimentary win and nix "chat" programs that exchange "data" in the archives from many years ago.
Good to know.
I submitted code to use socks connecting Eu to Mirc decades ago, both localhost and across the lan, and was roundly denounced.
That was before the gensis of the OE dev team, I believe. Today, you'd get a much more welcome reception, I guarantee.
If you are favorable to those "in charge", you will beome the deity of choice, else you will be ridiculed and forgotten. I don't even volunteer code any more (see irc.e , and the http.e-tasks-news.ex fiasco).
Speaking formally on behalf of both the dev team and the admin team, and also the moderator team, I can promise that no one will be ridiculed.
Speaking formally on behalf of the dev team, I can promise that any code that gets volunteered would be accepted today (albeit that the devs might make some modifications to make it look more similar to other parts of the stdlib and so on).
My "claim to fame" would be i hooked the type system to make sharing happen with only the one keyword. I used IPC, thinking it was faster, but i did no speed tests. I also was/am leery of the OS blocking on winsock calls in compiled OE, although this is not a problem running interpreted with tasks.e.
I would think you have much more than just this.
Good lucks to you.
Kat
Ditto.