roy@phri.UUCP (Roy Smith) (05/05/88)
Programs like rlogin, telnet, tip, kermit, etc. need to implement bi-directional communication; whatever you type has to be forwarded to "the other end" and whatever comes in from "the other end" has to be forwarded to your screen. The two ways I know to do this are to 1) use two processes, each handling one side of the connection, or 2) use a single process to handle both sides, select(2)ing on the 2 input file descriptors. Are the any generally-applicable rules as to which is more efficient (you may define efficiency in any terms you like, but please show all work to receive full credit). My gut feeling is that a single process would be more efficient in terms of memory, and probably in terms of CPU as well. I suppose a third alternative would be polling in a single process using non-blocking reads on both file descriptors, but I can't imagine that would do anything other than eat CPU time like crazy. -- Roy Smith, System Administrator Public Health Research Institute 455 First Avenue, New York, NY 10016 {allegra,philabs,cmcl2,rutgers}!phri!roy -or- phri!roy@uunet.uu.net