home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.21 / text0135.txt < prev    next >
Encoding:
Text File  |  1990-10-26  |  2.8 KB  |  63 lines

  1. Submitted-by: brnstnd@kramden.acf.nyu.edu (Dan Bernstein)
  2.  
  3. In article <546@usenix.ORG> henry@zoo.toronto.edu (Henry Spencer) writes:
  4. > I'm afraid I don't understand:  a program that is trying, simultaneously,
  5. > to open several different connections is somehow not doing several things
  6. > at once?
  7.  
  8. Correct. Between sending an open request out upon the network and
  9. receiving an acknowledgment, the program is not doing anything at all
  10. related to that connection.
  11.  
  12. Let me be more specific. Host X, on the Internet, wants to know the
  13. time. It decides to ask ten hosts around the network for the time.
  14.  
  15. In reality, here's what happens in X's interaction with Y: X sends to Y
  16. a request for a connection on port 37. Pause. Y acknowledges. Y sends a
  17. few bytes back and closes the connection. During the pause, X is doing
  18. nothing.
  19.  
  20. But there are several Y's. So X sends out ten requests in sequence. It
  21. waits. Each Y responds at some point; X collects the responses in
  22. whatever order they come. Where is it doing any two things at once, let
  23. alone several?
  24.  
  25. > The program *is* doing several things at once, to wit opening several
  26. > connections at once.
  27.  
  28. ``Opening a connection'' is really an abuse of the language, because a
  29. network open consists of at least two steps that may come arbitrarily
  30. far apart. Let me replace it by phrases that honestly describe what the
  31. computer is doing: ``sending out a connection request, and later
  32. accepting an acknowledgment.''
  33.  
  34. Now, out of the requests and acknowledgments going on, what two are
  35. happening at once? None of them. You're being misled by the terminology.
  36. ``Opening a connection'' is such a common phrase that we automatically
  37. accept it as a description of reality, and consequently believe that it
  38. is well described by open(); but it isn't. The time between request and
  39. acknowledgment is filled with nothing but a void.
  40.  
  41.   [ combining threads with a one-step open() ]
  42. > This is a far more natural model of what's
  43. > going on than forcing everything into one sequential process, and a
  44. > much better match for the semantics of the problem.
  45.  
  46. No. It is not an accurate description of what is going on, since an
  47. open() is implicitly local while a network open is not.
  48.  
  49. Abstract imagery aside, though, ``naturalness'' is really defined by how
  50. a concept helps a programmer. BSD's non-blocking connect() and select()
  51. for connection acceptance, while perhaps not the best-named system
  52. calls, are extremely easy to work with. They adapt perfectly to network
  53. programming problems because they accurately reflect what the system is
  54. doing. In contrast, forking off threads and kludging around a local
  55. open() is unnecessarily complex and would make network programming
  56. unnecessarily difficult. For me that condemns it as an unnatural,
  57. inaccurate reflection of reality.
  58.  
  59. ---Dan
  60.  
  61. Volume-Number: Volume 21, Number 135
  62.  
  63.