<rob_w>
good morning .. hello Regenaxer ... i still working me into my stuff and would love to get some attention from you by tomorrow , would that be possible ?
<Regenaxer>
Serus rob_w!
<Regenaxer>
yes, fine
<rob_w>
great thx
<Regenaxer>
Let's phone
<Regenaxer>
tomorrow, today I'm a bit busy
<rob_w>
tomorrow u mean ?
<rob_w>
yeah np
<Regenaxer>
T
<rob_w>
soi need to figure out a way to screen share ... what would you suggest ?
<Regenaxer>
We can use Jitsi, like for PilCon
<rob_w>
yep works for me ..
<rob_w>
nice
<Regenaxer>
good
<rob_w>
well Regenaxer .. a simple question .. how do i append log messages to your actual log file we use
<rob_w>
ah nvm
<Regenaxer>
I always redirect stderr from the start scripts
<Regenaxer>
you can also use 'err'
<aw->
hi rob_w Regenaxer
<aw->
Regenaxer: how do i detect when a client disconnects from a socket?
<Regenaxer>
Hi aw-
<aw->
i'm doing (in Sock ....) need to know if the client disconnected and won't send data anymore
<Regenaxer>
You get NIL
<Regenaxer>
yes
<Regenaxer>
Normally in a 'task'
<Regenaxer>
so the task wakes up
<aw->
without task'
<aw->
(if (in Sock ...) "still connected" "disconnected") ?
<Regenaxer>
This will block, but it is the same
<Regenaxer>
(in Sock (if (rd) (do something) (close Sock)))
<Regenaxer>
(rd) or (read) or (line), (char) etc
<aw->
hmmm
<aw->
is it bad practice to do (in Sock ...) (in Sock ...) ?
<Regenaxer>
no, this is fine
<Regenaxer>
or, it is normal
<Regenaxer>
How else?
<aw->
ok so in that case how do I know when the client is dead?
<Regenaxer>
As I said, only from the return value
<aw->
ex: (if (rd) (do something) (close Sock)) (if (rd) (do something else) (close Sock)) ..
<aw->
this is not good
<Regenaxer>
Why not?
<aw->
because (do something else) will never run
<Regenaxer>
Different places, right?
<Regenaxer>
If the socket is closed, you should not read from it, yes
<aw->
ok wait
<Regenaxer>
it will return NIL again, so no big problem
<aw->
so if a client does (out Sock (prinl 1)) (out Sock (prinl 2))
<Regenaxer>
yes
<aw->
ok wait, let me explain my use-case
<Regenaxer>
After (out ...) the socket is not closed
<Regenaxer>
you can call out many times
<aw->
how do I listen for multiple (out) calls?
<aw->
(loop (in Sock ...)) ?
<Regenaxer>
yes
<aw->
but then it never exits
<Regenaxer>
(in Sock (while (rd) ..)) (close Sock)
<aw->
no that's different
<aw->
(while (rd) expects multiple data on the same (out)
<aw->
it's different from multiple (out)
<Regenaxer>
no
<Regenaxer>
Don't care about *how* the sender sends the data
<Regenaxer>
(out S (pr 1)) (out S (pr 2)) is the same as (out S (pr 1 2))
<aw->
oh ok
<aw->
but (while (rd) blocks), right?
<Regenaxer>
yes
<aw->
it blocks until the socket is closed?
<Regenaxer>
until *something* arrives
<Regenaxer>
that *may* be EOF
<Regenaxer>
7
Regenaxer has left #picolisp [#picolisp]
Regenaxer has joined #picolisp
<Regenaxer>
Wifi unstable
<Regenaxer>
aw-, just experiment with two repls
<aw->
i've been doing that all day
<Regenaxer>
:)
<Regenaxer>
So where is the problem?
<aw->
if I knew, I wouldn't be asking ;)
<Regenaxer>
true ;)
<aw->
i'm playing with the boss.l and it's been difficult
<beneroth>
aw-, I like to second your distaste for IPv6. I started now with LXD (Linux containers + higher level API/management interface)... and as I didn't like the default iptables of it (vlan is fully trusted) I had to make all iptables/filtering myself.. and failed for ipv6 (I don't know ipv6 really). so solution was to disable it (not much value in a vlan anyway)...
<Regenaxer>
boss is easy if you are in a child started with psh
<Regenaxer>
(boss 'msg ''OK)
<Regenaxer>
just start the app/ demo
<Regenaxer>
then $ psh 8080
<aw->
how do I get out of (while (rd)) loop ?
<aw->
(pr (eof)) ?
<Regenaxer>
no, (close Sock)
<aw->
my client disconnects, but the server is still waiting for data on the socket which is clearly closed
<aw->
erik mentions "You may still have some main loop in your program"
<aw->
where would this 'main loop' go?
<Regenaxer>
it is either 'key' or 'wait'
<aw->
where do i add it in thecode?
<Regenaxer>
pil main.l -main -go -wait
<Regenaxer>
or (wait) somewhere
<Regenaxer>
Naturally always in the end
<aw->
right
<aw->
ok thanks
<Regenaxer>
to get a REPL, you do
<Regenaxer>
pil main.l -main -go +
<Regenaxer>
So it falls throug to the repl
<Regenaxer>
and thus 'key'
<aw->
(task) doesn't fork a process?
<beneroth>
aw-, no
<beneroth>
(task) stays in the same process
<Regenaxer>
T, it is just an asynchronous event handler
<beneroth>
basically during (wait) the installed tasks in *Run are checked and/or triggered by system calls (e.g. a socket connection has received data) and the associated prog executed
<beneroth>
(wait) is called implicitly by some other picolisp functions where it makes sense, e.g. (dbSync) etc., when waiting for I/O
<beneroth>
conceptually a process with (task)s installed is a bit similar to the parent process for forking children, as in you do all declarations and then usually spend most time in (wait) and execute the installed (tasks) whenever they trigger
<beneroth>
Regenaxer, correct, more or less?
<Regenaxer>
yes, very good
<Regenaxer>
The first statement could add that tasks also oay be timers
<Regenaxer>
may
<Regenaxer>
thus either I/O events or timeouts
<beneroth>
that is meant with 'main loop', after setup the process isn't doing much more then looping/waiting for tasks to trigger (or on forking server, for incoming connections, starting their handling, then continue waiting for next connections)
<beneroth>
of course the process can do additional things
<beneroth>
but.. it should spend time in (wait), because there the asynchronous stuff is triggered/executed
<beneroth>
the whole thing is maybe a bit hard to understand the first time, because the abstractions are less deep/nested as in other stacks
<beneroth>
other stacks run a full machinery of threads/background processes/similar, while the picolisp approach is more direct. but by default leaves away extra machinery which isn't needed for most cases
<beneroth>
Regenaxer, maybe one could even say that picolisp asynchronous executions ('task, stuff executed by 'tell) is kinda like threads without scheduling, no?
<beneroth>
what triggers first comes first, if the prog contains a (wait) (or I/O) this of course gives other asynchronous stuff a point to trigger...
<Regenaxer>
Not sure. Threads have more parallelism
<beneroth>
T
<Regenaxer>
Threads are more like child processes, just in the same memory
<beneroth>
picolisp is concurrency, not parallelism
<Regenaxer>
cooperative, like coroutines
<Regenaxer>
coroutines are like cooperative threads
<beneroth>
Regenaxer, threads are funny.. the main point is having the same memory (vs. processes), but most newer stacks go pretty far to reduce the "same memory" feature so it's getting easier to handle (e.g. non-destructive memory)
<Regenaxer>
hehe, yeah
<Regenaxer>
threads are the new goto
<beneroth>
same as goto their perfect for certain special cases when used correctly, but should not used lightly
<Regenaxer>
T
<beneroth>
I like to add the same applies to distributed databases, or actually network-distributed anything
orivej_ has quit [Ping timeout: 260 seconds]
orivej has joined #picolisp
<Regenaxer>
So I would say 'task' (which is just a front-end to '*Run' is THE workhorse of PicoLisp
<Regenaxer>
It is the "outer interpreter"
<Regenaxer>
(if 'eval' is the "inner interpreter")
<Regenaxer>
In that view, the REPL is also just an entry in *Run or 'task'
<Regenaxer>
I think most people are not aware of this
rob_w has quit [Remote host closed the connection]
orivej has quit [Ping timeout: 260 seconds]
orivej has joined #picolisp
<beneroth>
T for your applications, and in way for most server applications
<beneroth>
for basic scripting (instead of bash scripting) 'task' is usually not needed (useful for some cases maybe) :-)
<Regenaxer>
right
<Regenaxer>
But even such scripts are usually tested in a repl
<Regenaxer>
The terms "inner" and "outer" interpreter are also from Forth btw
<Regenaxer>
the outer one in Forth is a repl though
<beneroth>
I see, interesting!
orivej has quit [Ping timeout: 264 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 260 seconds]
orivej has joined #picolisp
patrixl has quit [Quit: Leaving.]
patrixl has joined #picolisp
orivej has quit [Ping timeout: 256 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 264 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 264 seconds]
orivej_ has joined #picolisp
mtsd has quit [Quit: Leaving]
Blue_flame has joined #picolisp
Blue_flame is now known as Guest68669
orivej_ has quit [Ping timeout: 246 seconds]
orivej has joined #picolisp
orivej has quit [Ping timeout: 258 seconds]
orivej has joined #picolisp
orivej has quit [Quit: No Ping reply in 180 seconds.]
orivej has joined #picolisp
Guest68669 is now known as Blue_flame
orivej has quit [Quit: No Ping reply in 180 seconds.]
orivej has joined #picolisp
orivej has quit [Quit: No Ping reply in 180 seconds.]