Am Mittwoch, den 09.07.2008, 23:14 +0200 schrieb Hans Bulfone: > hi, > > On Wed, Jul 09, 2008 at 02:22:45PM +0200, Jörg F. Wittenberger wrote: > > Hi all, > > > > I wanted to control tcp connections from chicken, but handle the actual > > traffic by an external program. > > > > This appears not quite possible with the tcp unit as it stands. > > tcp-accept starts reading from the accepted connection while my > > connection handler starves. (Or at worst they will share the traffic in > > an unpredictable way.) > > > > To cope with the situation I added "tcp-get-next-client" (which is > > incidentally compatible with rscheme's "get-next-client", since that's > > the code I'm porting). > > > > Is this a general useful addition? I'd appreciate if it would it make > > it into chicken. Will it? > > i cannot decide this, but i have a question: > > your code looks just like tcp-accept (from chicken 3.1.0) except that > you return (values fd (##net#getpeername fd)) and tcp-accept returns > (##net#io-ports fd).
Yes, it's just this slight modification. > i don't understand why wrapping the fd in scheme ports should read > anything from the fd if the ports are not used in any way besides > getting the fd out (which doesn't seem to be possible right now - > perhaps also a useful addition :) This is actually possible using port->fileno. I tried this first and got a valid fd; the writing side (chicken -> connection handler) did work well. But reading from connection handler was a mess. > otoh... ##net#io-ports makes the fd non-blocking which it should > and closes them at > some point so you are probably right, a lower-level function should be > available that just returns the plain fd. (and tcp-accept should then > just be (##net#io-ports (tcp-get-next-client-or-something tcpl)) > > i'd prefer tcp-accept* or tcp-accept/fd over tcp-get-next-client. Since this is an single, isolated code spot in my 100kLOC to be ported, I don't mind any name. function first: I want it to fly /Jörg _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users