beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
alexshe38 has quit [Read error: Connection reset by peer]
alexshendi has joined #picolisp
<abu[7]> jj
<abu[7]> Hi beneroth_, alexshendi!
<abu[7]> !
<abu[7]> You should close the task with (task (close Fd))
<abu[7]> Examples in @lib/http.l and @lib/xhtml.l
<beneroth_> good morning abu[7]
<beneroth_> yeah I figured
<beneroth_> so my plan is to have a list or idx of opened connections, and close them when not used for a certain time. e.g. with a timeout task which closes and disposes all connections which were not marked active since last run, and marking them on every request
<beneroth_> that sounds good?
<beneroth_> goal is to have long-living process which handles requests
beneroth_ has quit [Quit: Leaving]
beneroth has joined #picolisp
<abu[7]> Not needed, just (let Fd @ (in Fd (if (rd) ... (task (close Fd)))))
<beneroth> I don't want to close after every request
<abu[7]> No, Fd is closed automatically and (rd), (read) etc return NIL if the remote client terminated
<beneroth> yeah, but I also don't want to keep them forever when they don't send data but keep the connection
<abu[7]> How to restart the task?
<beneroth> I also register a task for every fd
<beneroth> or what do you mean by restart?
<abu[7]> No, just one task
<abu[7]> I don't see the problem
<abu[7]> One task per socket
<beneroth> yes
<abu[7]> which closes itself
<abu[7]> upon eof
<beneroth> when triggered but then not able to read an expected message, yes
<abu[7]> T
<beneroth> when the other end closes correctly, the task gets triggered, correct? I think I noticed that during testing
<beneroth> when the other end does not close, the task keeps registered and inactive. right?
<abu[7]> There is no way to close it "incorrectly"
<abu[7]> No
<abu[7]> you get eof
<beneroth> pulling the cable on the other end?
<beneroth> will that trigger the task?
<beneroth> I get the eof upon reading attempt, but what if no reading attempt gets made because the task didn't get triggered?
<abu[7]> Then it tokes a long time
<beneroth> yep
<beneroth> not forever, granted
<beneroth> but quite long, afaik.
<abu[7]> T
<abu[7]> Does this happen frequently?
<beneroth> and there is also the situation (only in public with potentially hostile clients, no problem in controlled environment) when clients keep connections open but don't use them, be it bad programming or targeted resource/fd exhaustion. right?
<beneroth> abu[7], good question :D
<abu[7]> If you have a task per client anyway, I see no problem
<abu[7]> Just many tasks ☺
<beneroth> yep
<abu[7]> But the clean up is best done upon EOF
<beneroth> T
<beneroth> any problems if I de-register the task and close the socket without reading? not on my end, right?
<abu[7]> Yes, thats fine. The client must cope with it :)
<beneroth> thanks :)
<geri> is there a built-in function for flattening lists?
<abu[7]> (fish atom Lst)
<geri> nice, thanks
bjorkint0sh has joined #picolisp
bjorkintosh has quit [Ping timeout: 260 seconds]
<beneroth> whats the best way to get the number of nodes in an idx tree? (depth) and @@ ?
<abu[7]> Yes, this is the best
<beneroth> thanks ☺
alexshe22 has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]
<geri> hey, how could i pipe stdio from picolisp to sed?
<geri> i kinda forgot ~w~
<abu[7]> (in '("sed" ...) ... ?
<geri> probably either pipe, in or out (or both of them), but cant get it to work atm
<geri> sec
<abu[7]> or 'pipe', yes
<geri> (out '(sed "s/H/X/g") (prinl "Hello")) seems to have worked
<geri> whic is weird but okay :D
<geri> found out about text today, its nice
<abu[7]> Pipes are a bit tricky
<abu[7]> examples: http://pb1n.de/?2d7da2
<geri> lovely pipe pipe pipe
<abu[7]> 'ls | grep "M" | tr ..' in 2 versions
<geri> makes sense
<abu[7]> (fd 0) is the trick
<abu[7]> 'dup's the fd
<abu[7]> stdout
<abu[7]> '("sh" "-c" .. is easier ;)
<geri> actually out sed doesnt work anymore
<geri> XD
<geri> magic
<geri> and in '(sed ...) returns
<geri> sed: read error on stdin: Input/output error
<abu[7]> (in NIl ... ?
<geri> in NIL works fine
<abu[7]> otherwise it is the current input channel (eg. the scipt
<geri> is very weird
ygrek has joined #picolisp
alexshe22 has quit [Read error: Connection reset by peer]
alexshendi has joined #picolisp
<beneroth> when you see magic, then closer watching the trick you should.
<beneroth> the real magic you feel when you see the harmony.
<geri> xd
<geri> *disappears to bed*
<abu[7]> Good night!
<geri> thanks 🛌
geri has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.3)]
<beneroth> sweet dreams of programming elegance :D
alexshe7 has joined #picolisp
alexshendi has quit [Ping timeout: 260 seconds]
alexshendi has joined #picolisp
alexshe7 has quit [Ping timeout: 252 seconds]
alexshendi has quit [Read error: Connection reset by peer]
alexshendi has joined #picolisp
ygrek has quit [Remote host closed the connection]
alexshe80 has joined #picolisp
alexshendi has quit [Read error: Connection reset by peer]