KraftDiner wrote: > Thanks I can't seem to get this example to do anything except sit > there.... > http://docs.python.org/lib/asyncore-example.html
Yeah, the example code, by itself, will just sit there. As an example, it should probably include the calls to make it do something. Try adding the following lines to the given code: http_client('www.python.org', '/') asyncore.loop() The call: "asyncore.loop()" is what says to stop just sitting there and do something. > And still it seems like a lot of work for a simple send/expect script. > I got the makefile to work.. there is a readline function how does one > use writelines to write one single line? I don't yet have my head around what you are asking. Reading exactly up to end-of-line from a socket can be a bit tricky, but I think I can explain. Managing multiple input sources and their blocking behavior is a basic problem -- so basic that we've already examined and debated the alternatives. Writing exactly one line is trivial. I found Marc 'BlackJack' Rintsch's response a bit misleading. The asyncore module offers nothing to read a line. The asynchat module will respond to lines if you pass set_terminator() the end-of-line marker. I had to read both the doc and the source to figure out what should work. Sybren Stuvel pointed out socket.makefile(), which will read up to the end of line, but does not play nice with others. Its local buffering pretty much breaks select(). If you set any timeout and the timeout raises, the documented interface does not provide any way to tell what data was sent and received. Jean-Paul Calderone suggested Twisted; it has a lot of fans, and I'm not competent to say how well it would work in this case. I've never been willing, nor seen the need, to re-write all code in Twisted's deferred form. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list