home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / programm / 6071 < prev    next >
Encoding:
Text File  |  1993-01-28  |  3.4 KB  |  70 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!paladin.american.edu!howland.reston.ans.net!usc!sdd.hp.com!decwrl!pa.dec.com!engage.pko.dec.com!nntpd.lkg.dec.com!news!alpha.aosg.gsf.dec.com!gaf
  3. From: gaf@alpha.aosg.gsf.dec.com (Gerald Feldman)
  4. Subject: Re: client/server question.....
  5. Message-ID: <1993Jan27.223124.22279@aosg.gsf.dec.com>
  6. Sender: usenet@aosg.gsf.dec.com (USENET News System)
  7. Nntp-Posting-Host: alpha.aosg.gsf.dec.com
  8. Reply-To: gaf@aosg.gsf.dec.com
  9. Organization: Digital Equipment Corporation
  10. References: <1993Jan26.221617.53627@slate.mines.colorado.edu> <1k6fa5INN1m6@opsin.cs.unc.edu>
  11. Date: Wed, 27 Jan 1993 22:31:24 GMT
  12. Lines: 56
  13.  
  14. In article <1k6fa5INN1m6@opsin.cs.unc.edu>, panvalka@cs.unc.edu (Anay Panvalkar) writes:
  15. |> In article <1993Jan26.221617.53627@slate.mines.colorado.edu> iarit@slate.mines.colorado.edu (ARIT ISMAIL) writes:
  16. |> 
  17. |> >I don't want to fork because the info should be generated on one
  18. |> >program, send to server and the server has to respond to every
  19. |> >program connected with the same info( if I fork, how can I transfer
  20. |> >that info to child?).
  21. |> 
  22. |> One solution is open a temp. file and write your info to it.
  23. |> Then when you fork() the child will get its own copy of the
  24. |> parent's descriptors. But, if the child modifies this info,
  25. |> it will affect any later read or writes to it by the parent.
  26. |> 
  27. |> > check_new_connection(); /* how can I check if there is any new
  28. |> >                           without waiting, as far as I know accept(..)
  29. |> >                           blocks you 'till you get some connection*/
  30. |> 
  31. |> Well, read the man page for select(2)...
  32. |>      Selecting true for reading on a socket descriptor upon which
  33. |>      a  listen(2) call has been performed indicates that a subse-
  34. |>      quent accept(2) call on that descriptor will not block.
  35. |> 
  36. |> >My problem is getting new connections without waiting.
  37. |> >I appreciate any help.
  38. |> >iarit@slate.mines.colorado.edu
  39. |> 
  40. |> -Anay
  41. |> 
  42. |> --
  43. |> ===============================================================================
  44. |> Anay S. Panvalkar
  45. |> Biomedical Engineering                  ****GO TARHEELS****
  46. |> University of North Carolina        
  47.  
  48. -- 
  49. Maybe a more appropriate solution is to use threads (or lightweight
  50. processes). With threads, your program is viewed as a single process by
  51. the OS (although the Kernel does know about Kernel threads). Also, if
  52. you use Posix threads your application will be somewhat portable between
  53. operating systems and platforms. Your application could be more easily
  54. ported to Sun, Digital Unix (Ultrix or OSF/1), Digital VMS, HP-UX.
  55. Your global memory is shared by each thread, but each thread has its own
  56. stack. This approach eliminates keeping a temp file. It also eliminates
  57. the non-portability of using a shared memory or IPC solution. The only
  58. real problem is that the Posix threads standard is subject to change.
  59. But, this is probably the most portable solution, and it does not lock
  60. your application into anyone's hardware or OS since threads can be
  61. implemented on many different types of operating systems.
  62. +-------------------------------------------------------------+
  63. Jerry Feldman           AOSG
  64. Mailstop: GSF1-1/K13       DTN:264-5863
  65. Digital Equipment Corp.    EXT:(603)884-5863
  66. 5 Wentworth Drive          ip(DEC): gaf@aosg.gsf.dec.com
  67. Hudson, NH 03051           enet: alpha::gaf
  68.                Internet(HOME):gaf@palantir.newton.ma.us
  69. +-------------------------------------------------------------+
  70.