robertbira

Italian Translation Report: Node.js [Part 46 - 1106 words]

Oct 18th, 2018
105
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. UDP / Datagram Sockets
  2. The module provides an implementation of UDP Datagram sockets.
  3. The object is an that encapsulates the datagram functionality.
  4. New instances of are created using
  5. The keyword is not to be used to create instances.
  6. The event is emitted after a socket is closed with
  7. Once triggered, no new events will be emitted on this socket.
  8. The event is emitted whenever any error occurs.
  9. The event handler function is passed a single object.
  10. The event is emitted whenever a socket begins listening for datagram messages.
  11. This occurs as soon as UDP sockets are created.
  12. The event is emitted when a new datagram is available on a socket.
  13. The event handler function is passed two arguments: and
  14. The message.
  15. Remote address information.
  16. The sender address.
  17. The address family
  18. The sender port.
  19. The message size.
  20. Tells the kernel to join a multicast group at the given and using the socket option.
  21. If the argument is not specified, the operating system will choose one interface and will add membership to it.
  22. To add membership to every available interface, call multiple times, once per interface.
  23. Returns an object containing the address information for a socket.
  24. For UDP sockets, this object will contain and properties.
  25. with no parameters.
  26. Called when binding is complete.
  27. For UDP sockets, causes the to listen for datagram messages on a named and optional
  28. If is not specified or is, the operating system will attempt to bind to a random port.
  29. If is not specified, the operating system will attempt to listen on all addresses.
  30. Once binding is complete, a event is emitted and the optional function is called.
  31. Note that specifying both a event listener and passing a to the method is not harmful but not very useful.
  32. A bound datagram socket keeps the Node.js process running to receive datagram messages.
  33. If binding fails, an event is generated.
  34. In rare case (e.g. attempting to bind with a closed socket), an may be thrown.
  35. Example of a UDP server listening on port 41234:
  36. Required.
  37. Supports the following properties:
  38. The object may contain an additional property that is use when using objects with the module.
  39. When is set to (the default), cluster workers will use the same underlying socket handle allowing connection handling duties to be shared.
  40. When is, however, the handle is not shared and attempted port sharing results in an error
  41. An example socket listening on an exclusive port is shown below.
  42. Close the underlying socket and stop listening for data on it.
  43. If a callback is provided, it is added as a listener for the event.
  44. Instructs the kernel to leave a multicast group at using the socket option.
  45. This method is automatically called by the kernel when the socket is closed or the process terminates, so most apps will never have reason to call this.
  46. If is not specified, the operating system will attempt to drop membership on all valid interfaces.
  47. Returns: the socket receive buffer size in bytes.
  48. By default, binding a socket will cause it to block the Node.js process from exiting as long as the socket is open.
  49. The method can be used to exclude the socket from the reference counting that keeps the Node.js process active.
  50. The method adds the socket back to the reference counting and restores the default behavior.
  51. Calling multiples times will have no additional effect.
  52. The method returns a reference to the socket so calls can be chained.
  53. Message to be sent.
  54. Offset in the buffer where the message starts.
  55. Number of bytes in the message.
  56. Destination port.
  57. Destination hostname or IP address.
  58. Called when the message has been sent.
  59. Broadcasts a datagram on the socket.
  60. The destination and must be specified.
  61. The argument contains the message to be sent.
  62. Depending on its type, different behavior can apply.
  63. If is a or the and specify the offset within the where the message begins and the number of bytes in the message, respectively.
  64. If is a, then it is automatically converted to a with encoding.
  65. With messages that contain multi-byte characters, and will be calculated with respect to and not the character position.
  66. If is an array, and must not be specified.
  67. The argument is a string.
  68. If the value of is a host name, DNS will be used to resolve the address of the host.
  69. If is not provided or otherwise falsy, (for sockets) or will be used by default.
  70. If the socket has not been previously bound with a call to, the socket is assigned a random port number and is bound to the "all interfaces" address
  71. An optional function may be specified to as a way of reporting DNS errors or for determining when it is safe to reuse the object.
  72. Note that DNS lookups delay the time to send for at least one tick of the Node.js event loop.
  73. The only way to know for sure that the datagram has been sent is by using a
  74. If an error occurs and a is given, the error will be passed as the first argument to the
  75. If a is not given, the error is emitted as an event on the object.
  76. Offset and length are optional but both must be set if either are used.
  77. They are supported only when the first argument is a or
  78. Sending multiple buffers might be faster or slower depending on the application and operating system.
  79. It is important to run benchmarks to determine the optimal strategy on a case-by-case basis.
  80. Generally speaking, however, sending multiple buffers is faster.
  81. A Note about UDP datagram size
  82. The maximum size of an datagram depends on the (Maximum Transmission Unit) and on the field size.
  83. The field is wide, which means that a normal payload exceed 64K octets including the internet header and data this is generally true for loopback interfaces, but such long datagram messages are impractical for most hosts and networks.
  84. The is the largest size a given link layer technology can support for datagram messages.
  85. For any link, mandates a minimum of octets, while the recommended for IPv4 is (typically recommended as the for dial-up type applications), whether they arrive whole or in fragments.
  86. For, the minimum is octets, however, the mandatory minimum fragment reassembly buffer size is octets.
  87. The value of octets is very small, since most current link layer technologies, like Ethernet, have a minimum of
  88. It is impossible to know in advance the MTU of each link through which a packet might travel. Sending a datagram greater than the receiver MTU will not work because the packet will get silently dropped without informing the source that the data did not reach its intended recipient.
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×