socketsessionreceiver_inc.cc 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. namespace {
  2. // Modifications
  3. // - about return value
  4. // - socket session "utility" => module
  5. const char* const SocketSessionReceiver_doc = "\
  6. The receiver of socket sessions.\n\
  7. \n\
  8. An object of this class holds a UNIX domain socket for an established\n\
  9. connection, receives socket sessions from the remote forwarder, and\n\
  10. provides the session to the application as a tuple of corresponding\n\
  11. elements.\n\
  12. \n\
  13. Note that this class is instantiated with an already connected socket;\n\
  14. it's not a listening socket that is accepting connection requests from\n\
  15. forwarders. It's application's responsibility to create the listening\n\
  16. socket, listen on it and accept connections. Once the connection is\n\
  17. established, the application would construct a SocketSessionReceiver\n\
  18. object with the socket for the newly established connection. This\n\
  19. behavior is based on the design decision that the application should\n\
  20. decide when it performs (possibly) blocking operations (see\n\
  21. socketsession module for more details).\n\
  22. \n\
  23. See the description of socketsession module for other details of how\n\
  24. the session forwarding works.\n\
  25. \n\
  26. SocketSessionReceiver(socket)\n\
  27. \n\
  28. The constructor.\n\
  29. \n\
  30. Exceptions:\n\
  31. TypeError The given parameter is not a valid socket object\n\
  32. SocketSessionError Any error on an operation that is performed\n\
  33. on the given socket as part of initialization.\n\
  34. SystemError Unexpected errors such as resource allocation failure\n\
  35. \n\
  36. Parameters:\n\
  37. socket A python socket object of a UNIX domain family for an\n\
  38. established connection with a forwarder.\n\
  39. \n\
  40. ";
  41. // Modifications
  42. // - socket session utility -> module
  43. // - return value (not a SocketSession object, but a Python tuple)
  44. // - remove the validity note (we copy it here, so there's no such
  45. // restriction)
  46. // - caller's responsibility: only responsible for closing the socket.
  47. // - text around the bullets
  48. // - exception
  49. const char* const SocketSessionReceiver_pop_doc = "\
  50. pop() -> (socket, socket address, socket address, byte)\n\
  51. \n\
  52. Receive a socket session from the forwarder.\n\
  53. \n\
  54. This method receives wire-format data (see socketsession module) for\n\
  55. a socket session on the UNIX domain socket, performs some validation\n\
  56. on the data, and returns the session information as a tuple.\n\
  57. \n\
  58. The caller is responsible for closing the received socket.\n\
  59. \n\
  60. It ensures the following:\n\
  61. \n\
  62. - The socket's address family is either AF_INET or AF_INET6\n\
  63. - The family element of the socket addresses for the local and remote\n\
  64. end points must be equal to the socket's address family\n\
  65. - The socket session data is not empty and does not exceed 65535\n\
  66. bytes.\n\
  67. \n\
  68. If the validation fails or an unexpected system error happens\n\
  69. (including a connection close in the meddle of reception), it throws\n\
  70. an SocketSessionError exception. When this happens, it's very\n\
  71. unlikely that a subsequent call to this method succeeds, so in\n\
  72. reality the application is expected to destruct it and close the\n\
  73. socket in such a case.\n\
  74. \n\
  75. Exceptions:\n\
  76. SocketSessionError Invalid data is received or a system error on\n\
  77. socket operation happens.\n\
  78. SystemError Unexpected errors such as resource allocation failure\n\
  79. \n\
  80. Return Value(s): A tuple corresponding to the extracted socket session:\n\
  81. socket A Python socket object corresponding to the socket passed\n\
  82. by the forwarder\n\
  83. socket address A Python socket address (which is a tuple) for the local\n\
  84. end point\n\
  85. socket address A Python socket address for the remote endpoint\n\
  86. data A Python byte object that stores the session data\n\
  87. ";
  88. } // unnamed namespace