On Sat, Dec 19, 2009 at 10:05:24AM +0100, Alexander Burger wrote:
> 1. Fork for each transaction:
> 
>       (task (port 4000)  # Background task listening on port 4000
>          (when (setq Sock (accept @))  # Accept a connection
>             (unless (fork)  # Child process
>                (task P)
>                (close P)  # Close port in child process
>                (in Sock
>                   (match ...)  # Read payload data
>                   (ht:Read ...)
>                   (dosomething) )
>                (bye) )  # Exit child process
>             (close Sock) ) )  # Close socket in parent process

Henrik just pointed out in IRC that 'P' is not bound.

In fact, the two lines

>                (task P)
>                (close P)  # Close port in child process

are not really needed here. They are necessary only when the child
process would last longer, and do some event handling on its own.

So I would use the corrected version:

      (task (port 4000)  # Background task listening on port 4000
         (let? Sock (accept @)  # Accept a connection
            (unless (fork)  # Child process
               (in Sock
                  (match ...)  # Read payload data
                  (ht:Read ...)
                  (dosomething) )
               (bye) )  # Exit child process
            (close Sock) ) )  # Close socket in parent process

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to