/libs/codeintel2/lib_srcs/node.js/dgram.js

http://github.com/Kronuz/SublimeCodeIntel · JavaScript · 125 lines · 19 code · 6 blank · 100 comment · 0 complexity · e617ab71ee4738f84f7cedf4d509e09a MD5 · raw file

  1. /**
  2. * Datagram sockets are available through require('dgram'). Datagrams are
  3. * most commonly handled as IP/UDP messages but they can also be used over
  4. * Unix domain sockets.
  5. */
  6. var dgram = {};
  7. /**
  8. * Creates a datagram socket of the specified types. Valid types are: udp4,
  9. * udp6, and unix_dgram.
  10. * @param type
  11. * @param callback
  12. * @returns dgram.Socket
  13. */
  14. dgram.createSocket = function(type, callback) {}
  15. dgram.Socket = function() {}
  16. dgram.Socket.prototype = {}
  17. /**
  18. * Tells the kernel to join a multicast group with IP_ADD_MEMBERSHIP socket
  19. * option.
  20. * @param multicastAddress
  21. * @param multicastInterface
  22. */
  23. dgram.Socket.prototype.addMembership = function(multicastAddress, multicastInterface) {}
  24. /**
  25. * For UDP sockets, listen for datagrams on a named port and optional
  26. * address. If address is not specified, the OS will try to listen on all
  27. * addresses.
  28. * @param port
  29. * @param address
  30. */
  31. dgram.Socket.prototype.bind = function(port, address) {}
  32. /**
  33. * Sets the IP_MULTICAST_TTL socket option. TTL stands for "Time to Live,"
  34. * but in this context it specifies the number of IP hops that a packet is
  35. * allowed to go through, specifically for multicast traffic. Each router
  36. * or gateway that forwards a packet decrements the TTL. If the TTL is
  37. * decremented to 0 by a router, it will not be forwarded.
  38. * @param ttl
  39. */
  40. dgram.Socket.prototype.setMulticastTTL = function(ttl) {}
  41. /**
  42. * For UDP sockets, the destination port and IP address must be specified.
  43. * A string may be supplied for the address parameter, and it will be
  44. * resolved with DNS. An optional callback may be specified to detect any
  45. * DNS errors and when buf may be re-used. Note that DNS lookups will delay
  46. * the time that a send takes place, at least until the next tick. The only
  47. * way to know for sure that a send has taken place is to use the callback.
  48. * @param buf
  49. * @param offset
  50. * @param length
  51. * @param port
  52. * @param address
  53. * @param callback
  54. */
  55. dgram.Socket.prototype.send = function(buf, offset, length, port, address, callback) {}
  56. /**
  57. * Sets or clears the IP_MULTICAST_LOOP socket option. When this option is
  58. * set, multicast packets will also be received on the local interface.
  59. * @param flag
  60. */
  61. dgram.Socket.prototype.setMulticastLoopback = function(flag) {}
  62. /**
  63. * Sets the IP_TTL socket option. TTL stands for "Time to Live," but in
  64. * this context it specifies the number of IP hops that a packet is allowed
  65. * to go through. Each router or gateway that forwards a packet decrements
  66. * the TTL. If the TTL is decremented to 0 by a router, it will not be
  67. * forwarded. Changing TTL values is typically done for network probes or
  68. * when multicasting.
  69. * @param ttl
  70. */
  71. dgram.Socket.prototype.setTTL = function(ttl) {}
  72. /**
  73. * Sets or clears the SO_BROADCAST socket option. When this option is set,
  74. * UDP packets may be sent to a local interface's broadcast address.
  75. * @param flag
  76. */
  77. dgram.Socket.prototype.setBroadcast = function(flag) {}
  78. /**
  79. * Returns an object containing the address information for a socket. For
  80. * UDP sockets, this object will contain address and port. For Unix domain
  81. * sockets, it will contain only address.
  82. */
  83. dgram.Socket.prototype.address = function() {}
  84. /**
  85. * Close the underlying socket and stop listening for data on it. UDP
  86. * sockets automatically listen for messages, even if they did not call
  87. * bind().
  88. */
  89. dgram.Socket.prototype.close = function() {}
  90. /**
  91. * Opposite of addMembership - tells the kernel to leave a multicast group
  92. * with IP_DROP_MEMBERSHIP socket option. This is automatically called by
  93. * the kernel when the socket is closed or process terminates, so most apps
  94. * will never need to call this.
  95. * @param multicastAddress
  96. * @param multicastInterface
  97. */
  98. dgram.Socket.prototype.dropMembership = function(multicastAddress, multicastInterface) {}
  99. /** @__local__ */ var __events__ = {};
  100. /**
  101. * Emitted when a new datagram is available on a socket. msg is a Buffer
  102. * and rinfo is an object with the sender's address information and the
  103. * number of bytes in the datagram.
  104. * @param msg {buffer.Buffer}
  105. * @param rinfo {Object}
  106. */
  107. __events__.message = function(msg, rinfo) {};
  108. /**
  109. * Emitted when a socket starts listening for datagrams. This happens as
  110. * soon as UDP sockets are created. Unix domain sockets do not start
  111. * listening until calling bind() on them.
  112. */
  113. __events__.listening = function() {};
  114. /**
  115. * Emitted when a socket is closed with close(). No new message events will
  116. * be emitted on this socket.
  117. */
  118. __events__.close = function() {};
  119. exports = dgram;