> This is strange, when I test with simple data, for example:
> (setq Lst '((4 5 6) (7 8 9)))
> (println (eval> '+Agent 1 'setArticleWords (lit Lst)))
> Then everything works just fine, the data is stored properly and I get
> proper return values.
> Then when I run the real code I just breaks down:
> [import_feeds.l:7] !? (out Sock (pr (rest)))
> 5 -- Bad FD
It looks like the socket was closed.
> (class +Agent)
> (dm connect> (SockNum)
> (connect "localhost" (+ 4040 SockNum)))
> (dm sock> (A)
> (let SockNum (if (num? A) A (max 1 (/ (; A aid) 10000)))
> (: sock)
> (=: sock
> (let Sock (connect> This SockNum)
> (if Sock
> (call "sh" "-c"
> (pack "./p projects/rss-reader/word_index.l -go "
> SockNum " -wait >> index.log 2>&1 &"))
> (connect> This SockNum)))))))
> (dm eval> (A . @)
> (let? Sock (sock> This A)
> (out Sock (pr (rest)))
> (prog1 (in Sock (rd))
> (close Sock))))
The problem is that this works only once, because the socket is closed
after the first call to 'eval>'. The next call to 'sock>', however, will
return the 'sock' property of the agent.
Is it necessary to close the socket here? After all, you preserve the
socket in the agent. Otherwise, if you close the socket later, it would
be better to record this also in the agent:
(prog1 (in Sock (rd))
(=: sock NIL) )