home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / internal / 1620 < prev    next >
Encoding:
Text File  |  1992-07-26  |  3.9 KB  |  83 lines

  1. Newsgroups: comp.unix.internals
  2. Path: sparky!uunet!xavax!tybrin4!tybse1!swhite
  3. From: swhite@tybse1.uucp (William C. "Spike" White)
  4. Subject: Re: Multiple listeners on same socket
  5. Organization: Tybrin Corporation, Shalimar, FL
  6. Date: Sun, 26 Jul 1992 05:00:45 GMT
  7. Message-ID: <1992Jul26.050045.2207@tybse1.uucp>
  8. Summary: helper processes w/ shared memory
  9. Keywords: shared memory, sockets, IPC 
  10. References: <1992Jul22.034730.12159@menudo.uh.edu> <1992Jul23.084108.22337@rdg.dec.com>
  11. Lines: 70
  12.  
  13. In article <1992Jul23.084108.22337@rdg.dec.com> jfoy@narcy.gao.dec.com (John Foy) writes:
  14. >
  15. >In article <1992Jul22.034730.12159@menudo.uh.edu>, nagappa@menudo.uh.edu (Chaitanya Nagappa) writes:
  16. >|>[...]
  17. >|>Howdy all,
  18. >|>I need something equivalent to a socket, but that more than one process
  19. >|>can listen on. This is for multiple consumers, and the output from the
  20. >|>server can be picked up by any one of the consumers. In the simplest
  21. >|>scenario, I have two processes doing a "listen" on the same socket,
  22. >|>and only one of these process is trigerred to establish the circuit.
  23. >|>Yes, I know neither BSD sockets or TLI can do this. What is then the
  24. >|>alternative? Do I have to create my own virtual device?
  25. >|>
  26. >|>Message queues & FIFOs are not a viable alternative, as the information
  27. >|>once placed cannot be ...
  28. >|>[...]
  29. >|>The problem of statically placing this using standard IPC methods such as
  30. >|>message queues, FIFOs or shared memory is that by the time my processes
  31. >|>get around to receiving the info. (worst case scenario) the call might
  32. >|>have been cleared. So I need a phased communication of the info.
  33. >
  34. >I'm not sure what you mean by "phased communcation..."?
  35. >
  36. >I'm not entirely familiar with select etc... (being more of a VMS'r) but have
  37. >you considered semaphores? e.g. the server pool waits on a counting semaphore
  38. >which is incremented by the 'dispatching' process (I think you refer to this as
  39. >the 'spawned' process)...? This way only available servers respond...
  40. >
  41. >
  42. >    jf
  43.  
  44. I may be thinking of the same thing in UNIX terminology.  You would potentially
  45. have several programs, all reading and writing from some inter-process
  46. communication channel (semaphore, message queue or shared memory).  Let' pick
  47. shared memory -- it's the most versatile (and hardest to code?). 
  48.  
  49. One program would be your true server.  It would wait for client requests to
  50. appear in a designated portion of this shared memory.  It would write responses
  51. to another designated portion of this shared memory.  It would not have any
  52. networking code in it at all.
  53.  
  54. A second program would be a simplified inetd-like program.  That is, it would 
  55. listen for network connections from clients at a well-known TCP port number.  
  56. When it got a connection, it would fork (& exec?) a child to satisfy the 
  57. client's requests.  Then it would go back listening for more connections.
  58.  
  59. The child process would be just a "helper" process for the client. It would 
  60. read to and write from shared memory and the inherited socket. 
  61.  
  62. I think this is how some SQL server programs are implemented (except MUCH more 
  63. efficiently :-)). 
  64.  
  65. You might be able to coalesce the inetd-like network listener and the child
  66. "helper" programs also.  Listen for connections, if you get one add it to the
  67. appropriate filemask, then do a select() and sequentially satisfy all clients
  68. requesting info.  You'd still use shared memory w/ a "back-end" true server.
  69. Sounds difficult to code.
  70.  
  71. Or you might coalesce the "back-end" server into the inetd-like listener, too. 
  72. That saves the shared memory coding -- client requests would be looked up 
  73. in the program's memory -- but it sounds EXTREMELY difficult to code.  You'd
  74. still listen for connections, add to the filemask, do a select() and satisfy
  75. all clients requesting info.
  76.  
  77.  
  78.  
  79. -- 
  80. Spike White     Tybrin Corporation, Shalimar, FL | Moderation in all things --
  81. swhite@afseo.eglin.af.mil                        | and abstinence in none! 
  82. Disclaimer: I speak only for myself, not my employer. 
  83.