chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Reading from TCP sockets and time outs


From: felix
Subject: Re: [Chicken-users] Reading from TCP sockets and time outs
Date: Sun, 11 Apr 2004 15:20:47 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113

Kim wrote:
Greetings --

I am a fairly new user to Chicken, and I have been wrestling with a problem that I have not yet managed to figure out soley within Chicken.
I am started to suspect I may have to skip out through the FFI to solve
it.

What I would like to have are threads that can wait/block until one of
three events happen:
  1) time out
  2) Data ready to be read on a (tcp) port/file descriptor
  3) Another thread sends a message/signal to unblock the waiting thread

Right now, what I am trying is to have the thread manually set a timeout
with ##sys#thread-block-for-timeout! and the wait on the socket with
##sys#thread-block-for-i/o!, then calling (thread-yield!).  When
the thread unblocks, I am using (file-select) to check to see if the
socket had data to be read, otherwise I check for a time out.
This does not quite seem to be working.  Ideally, I would also like
to be able to use (##sys#thread-unblock!) or something similiar to
wake up a thread that is otherwise blocked on a time out or a socket.


Yes, the threading stuff in Chicken is more designed towards being
simple and SRFI-18 compliant, instead having a clean and general
API for doing blocking/unblocking. Currently a thread can either
block on timeout, on I/O or on termination of another thread.
Blocking for timeout can be combined with blocking for termination
(incidentally). messages (i.e. mailboxes) work by solely using
thread-suspend!/-resume!.

I will try to find a solution for this problem (blocking on TO, I/O and
messages). If you would have any ideas for a decent API, please tell.


cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]