chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Is there a way to get tcp-accept to time-out?


From: Ed Watkeys
Subject: Re: [Chicken-users] Is there a way to get tcp-accept to time-out?
Date: Fri, 25 Feb 2005 10:40:03 -0500


On Feb 25, 2005, at 9:58 AM, Julian Morrison wrote:

An alternative is to write a simple C procedure that can grab the fd from the socket, so it can be passed to file-select.

Looks like (file-select) is already a wrapper, but it appears to be a low-level one, ie: all the disadvantages of using C directly. And (port->fileno) will grab FDs.

So my problem is solved, except that it isn't solved at all.

I'd rather not have to deal with select's blocking and its interaction with Chicken's threads at the C level.

The whole point of using select is to avoid threading. Still, IIRC chicken's threads are cooperative, so just call (file-select) with very small timeouts, and yield the thread. You can count the small timeouts to do a large timeout, or use (current-milliseconds).

I'm going to investigate using a signal handler to deal with my problem. After all, I don't care about returning from TCP-ACCEPT every x seconds. The point of timing-out is to check if someone has requested a server shutdown. I just need to make sure the appropriate (TCP-ACCEPT-ing) thread is interrupted by the signal.

I'm not that enamored with threads. I'd prefer to write either a pure select-based, event-driven server or a traditional fork-based server. Threads provide the implementation ease of the forking model with the shared state of the select-based model. I don't think I'm thinking Scheme-ly enough: with continuations, writing a select-based server would be a relative breeze. Time to think...

Ed





reply via email to

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