Hi Tomas,
> I attach a simple non-blocking echo server. There are some functions
Nice!
> Conceptually it should not block, I am not sure how to test it though.
> Any ideas?
Positive testing works well:
abu:~/pico ./p dbg.l nb-ex.l
: (more *Run)
(5 (when (accept @) (task @ Sock @ (callback Sock))))
-> NIL
second process
abu:~/pico ./p dbg.l
: (connect "localhost" 4444)
-> 3
: (out 3 (wr 1 2 3 254 255))
-> 255
first process
callback 3 J=0 I=0 N=5
read 5
written 5
rotate J=5 I=5 N=5
end 3 J=0 I=0 N=5
: *B
-> (1 2 3 254 255)
: (more *Run)
(3 (job '((Sock . 3)) (callback Sock)))
(5 (when (accept @) (task @ Sock @ (callback Sock))))
-> NIL
:-)
The difficult thing might be the negative test. Perhaps send a *lot* of
data, and do some "ifconfig xxx down" in between?
> - buffer could be local for the sockets, so 'callback' should be a
> closure... I guess I would have to use 'job' but that's next lesson
> I have to look at:-)
There is already a closure for 'Sock'
(task (port 4444) # Listen on port 4444
(when (accept @) # A connect arrived
(task @ # Install another task on this socket
Sock @ # Keep the socket in the task's env
(callback Sock) ) ) )
resulted in (see above)
(3 (job '((Sock . 3)) (callback Sock)))
Strictly speaking, the 'Sock' variable would not be necessary here,
because '@' is already bound to the file descritor when the task's body
is called. So a simple
(task @ (callback @))
should also work. But you could put your buffer there:
(task @
Buffer (need 5)
(callback @ Buffer) )
or similar.
> There should really be -m32 switch in the 'gcc' function. It would
Thanks for the tip! I'll include it.
> also be useful if it would be possible optionally switch on -g without
> having to modify the gcc.l file.
I would use 'patch' in such a case:
(patch gcc
'(apply @A "-o" @Z)
(append '(apply) @A '("-g" "-o") @Z) )
Cheers,
- Alex
--
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]