PageRenderTime 68ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/Pods/Documentation/CocoaAsyncSocket/html/Classes/GCDAsyncUdpSocket.html

https://gitlab.com/mba811/tokaidoapp
HTML | 3584 lines | 1901 code | 1683 blank | 0 comment | 0 complexity | b3aefa7ecd4161218937f5aed8e5c737 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="html/html; charset=utf-8" />
  5. <title>GCDAsyncUdpSocket Class Reference</title>
  6. <meta id="xcode-display" name="xcode-display" content="render"/>
  7. <link rel="stylesheet" type="text/css" href="../css/styles.css" media="all" />
  8. <link rel="stylesheet" type="text/css" media="print" href="../css/stylesPrint.css" />
  9. <meta name="generator" content="appledoc 2.1 (build 858)" />
  10. </head>
  11. <body>
  12. <header id="top_header">
  13. <div id="library" class="hideInXcode">
  14. <h1><a id="libraryTitle" href="../index.html">CocoaAsyncSocket 0.0.1 </a></h1>
  15. <a id="developerHome" href="../index.html">Dustin Voss and Robbie Hanson</a>
  16. </div>
  17. <div id="title" role="banner">
  18. <h1 class="hideInXcode">GCDAsyncUdpSocket Class Reference</h1>
  19. </div>
  20. <ul id="headerButtons" role="toolbar">
  21. <li id="toc_button">
  22. <button aria-label="Show Table of Contents" role="checkbox" class="open" id="table_of_contents"><span class="disclosure"></span>Table of Contents</button>
  23. </li>
  24. <li id="jumpto_button" role="navigation">
  25. <select id="jumpTo">
  26. <option value="top">Jump To&#133;</option>
  27. <option value="overview">Overview</option>
  28. <option value="tasks">Tasks</option>
  29. <option value="class_methods">Class Methods</option>
  30. <option value="//api/name/familyFromAddress:">&nbsp;&nbsp;&nbsp;&nbsp;+ familyFromAddress:</option>
  31. <option value="//api/name/getHost:port:family:fromAddress:">&nbsp;&nbsp;&nbsp;&nbsp;+ getHost:port:family:fromAddress:</option>
  32. <option value="//api/name/getHost:port:fromAddress:">&nbsp;&nbsp;&nbsp;&nbsp;+ getHost:port:fromAddress:</option>
  33. <option value="//api/name/hostFromAddress:">&nbsp;&nbsp;&nbsp;&nbsp;+ hostFromAddress:</option>
  34. <option value="//api/name/isIPv4Address:">&nbsp;&nbsp;&nbsp;&nbsp;+ isIPv4Address:</option>
  35. <option value="//api/name/isIPv6Address:">&nbsp;&nbsp;&nbsp;&nbsp;+ isIPv6Address:</option>
  36. <option value="//api/name/portFromAddress:">&nbsp;&nbsp;&nbsp;&nbsp;+ portFromAddress:</option>
  37. <option value="instance_methods">Instance Methods</option>
  38. <option value="//api/name/beginReceiving:">&nbsp;&nbsp;&nbsp;&nbsp;- beginReceiving:</option>
  39. <option value="//api/name/bindToAddress:error:">&nbsp;&nbsp;&nbsp;&nbsp;- bindToAddress:error:</option>
  40. <option value="//api/name/bindToPort:error:">&nbsp;&nbsp;&nbsp;&nbsp;- bindToPort:error:</option>
  41. <option value="//api/name/bindToPort:interface:error:">&nbsp;&nbsp;&nbsp;&nbsp;- bindToPort:interface:error:</option>
  42. <option value="//api/name/close">&nbsp;&nbsp;&nbsp;&nbsp;- close</option>
  43. <option value="//api/name/closeAfterSending">&nbsp;&nbsp;&nbsp;&nbsp;- closeAfterSending</option>
  44. <option value="//api/name/connectToAddress:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToAddress:error:</option>
  45. <option value="//api/name/connectToHost:onPort:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToHost:onPort:error:</option>
  46. <option value="//api/name/connectedAddress">&nbsp;&nbsp;&nbsp;&nbsp;- connectedAddress</option>
  47. <option value="//api/name/connectedHost">&nbsp;&nbsp;&nbsp;&nbsp;- connectedHost</option>
  48. <option value="//api/name/connectedPort">&nbsp;&nbsp;&nbsp;&nbsp;- connectedPort</option>
  49. <option value="//api/name/delegate">&nbsp;&nbsp;&nbsp;&nbsp;- delegate</option>
  50. <option value="//api/name/delegateQueue">&nbsp;&nbsp;&nbsp;&nbsp;- delegateQueue</option>
  51. <option value="//api/name/enableBroadcast:error:">&nbsp;&nbsp;&nbsp;&nbsp;- enableBroadcast:error:</option>
  52. <option value="//api/name/getDelegate:delegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- getDelegate:delegateQueue:</option>
  53. <option value="//api/name/init">&nbsp;&nbsp;&nbsp;&nbsp;- init</option>
  54. <option value="//api/name/initWithDelegate:delegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- initWithDelegate:delegateQueue:</option>
  55. <option value="//api/name/initWithDelegate:delegateQueue:socketQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- initWithDelegate:delegateQueue:socketQueue:</option>
  56. <option value="//api/name/initWithSocketQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- initWithSocketQueue:</option>
  57. <option value="//api/name/isClosed">&nbsp;&nbsp;&nbsp;&nbsp;- isClosed</option>
  58. <option value="//api/name/isConnected">&nbsp;&nbsp;&nbsp;&nbsp;- isConnected</option>
  59. <option value="//api/name/isIPVersionNeutral">&nbsp;&nbsp;&nbsp;&nbsp;- isIPVersionNeutral</option>
  60. <option value="//api/name/isIPv4">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv4</option>
  61. <option value="//api/name/isIPv4Enabled">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv4Enabled</option>
  62. <option value="//api/name/isIPv4Preferred">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv4Preferred</option>
  63. <option value="//api/name/isIPv6">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv6</option>
  64. <option value="//api/name/isIPv6Enabled">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv6Enabled</option>
  65. <option value="//api/name/isIPv6Preferred">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv6Preferred</option>
  66. <option value="//api/name/joinMulticastGroup:error:">&nbsp;&nbsp;&nbsp;&nbsp;- joinMulticastGroup:error:</option>
  67. <option value="//api/name/joinMulticastGroup:onInterface:error:">&nbsp;&nbsp;&nbsp;&nbsp;- joinMulticastGroup:onInterface:error:</option>
  68. <option value="//api/name/leaveMulticastGroup:error:">&nbsp;&nbsp;&nbsp;&nbsp;- leaveMulticastGroup:error:</option>
  69. <option value="//api/name/leaveMulticastGroup:onInterface:error:">&nbsp;&nbsp;&nbsp;&nbsp;- leaveMulticastGroup:onInterface:error:</option>
  70. <option value="//api/name/localAddress">&nbsp;&nbsp;&nbsp;&nbsp;- localAddress</option>
  71. <option value="//api/name/localAddress_IPv4">&nbsp;&nbsp;&nbsp;&nbsp;- localAddress_IPv4</option>
  72. <option value="//api/name/localAddress_IPv6">&nbsp;&nbsp;&nbsp;&nbsp;- localAddress_IPv6</option>
  73. <option value="//api/name/localHost">&nbsp;&nbsp;&nbsp;&nbsp;- localHost</option>
  74. <option value="//api/name/localHost_IPv4">&nbsp;&nbsp;&nbsp;&nbsp;- localHost_IPv4</option>
  75. <option value="//api/name/localHost_IPv6">&nbsp;&nbsp;&nbsp;&nbsp;- localHost_IPv6</option>
  76. <option value="//api/name/localPort">&nbsp;&nbsp;&nbsp;&nbsp;- localPort</option>
  77. <option value="//api/name/localPort_IPv4">&nbsp;&nbsp;&nbsp;&nbsp;- localPort_IPv4</option>
  78. <option value="//api/name/localPort_IPv6">&nbsp;&nbsp;&nbsp;&nbsp;- localPort_IPv6</option>
  79. <option value="//api/name/maxReceiveIPv4BufferSize">&nbsp;&nbsp;&nbsp;&nbsp;- maxReceiveIPv4BufferSize</option>
  80. <option value="//api/name/maxReceiveIPv6BufferSize">&nbsp;&nbsp;&nbsp;&nbsp;- maxReceiveIPv6BufferSize</option>
  81. <option value="//api/name/pauseReceiving">&nbsp;&nbsp;&nbsp;&nbsp;- pauseReceiving</option>
  82. <option value="//api/name/performBlock:">&nbsp;&nbsp;&nbsp;&nbsp;- performBlock:</option>
  83. <option value="//api/name/readStream">&nbsp;&nbsp;&nbsp;&nbsp;- readStream</option>
  84. <option value="//api/name/receiveOnce:">&nbsp;&nbsp;&nbsp;&nbsp;- receiveOnce:</option>
  85. <option value="//api/name/sendData:toAddress:withTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- sendData:toAddress:withTimeout:tag:</option>
  86. <option value="//api/name/sendData:toHost:port:withTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- sendData:toHost:port:withTimeout:tag:</option>
  87. <option value="//api/name/sendData:withTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- sendData:withTimeout:tag:</option>
  88. <option value="//api/name/setDelegate:">&nbsp;&nbsp;&nbsp;&nbsp;- setDelegate:</option>
  89. <option value="//api/name/setDelegate:delegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- setDelegate:delegateQueue:</option>
  90. <option value="//api/name/setDelegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- setDelegateQueue:</option>
  91. <option value="//api/name/setIPVersionNeutral">&nbsp;&nbsp;&nbsp;&nbsp;- setIPVersionNeutral</option>
  92. <option value="//api/name/setIPv4Enabled:">&nbsp;&nbsp;&nbsp;&nbsp;- setIPv4Enabled:</option>
  93. <option value="//api/name/setIPv6Enabled:">&nbsp;&nbsp;&nbsp;&nbsp;- setIPv6Enabled:</option>
  94. <option value="//api/name/setMaxReceiveIPv4BufferSize:">&nbsp;&nbsp;&nbsp;&nbsp;- setMaxReceiveIPv4BufferSize:</option>
  95. <option value="//api/name/setMaxReceiveIPv6BufferSize:">&nbsp;&nbsp;&nbsp;&nbsp;- setMaxReceiveIPv6BufferSize:</option>
  96. <option value="//api/name/setPreferIPv4">&nbsp;&nbsp;&nbsp;&nbsp;- setPreferIPv4</option>
  97. <option value="//api/name/setPreferIPv6">&nbsp;&nbsp;&nbsp;&nbsp;- setPreferIPv6</option>
  98. <option value="//api/name/setReceiveFilter:withQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- setReceiveFilter:withQueue:</option>
  99. <option value="//api/name/setReceiveFilter:withQueue:isAsynchronous:">&nbsp;&nbsp;&nbsp;&nbsp;- setReceiveFilter:withQueue:isAsynchronous:</option>
  100. <option value="//api/name/setSendFilter:withQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- setSendFilter:withQueue:</option>
  101. <option value="//api/name/setSendFilter:withQueue:isAsynchronous:">&nbsp;&nbsp;&nbsp;&nbsp;- setSendFilter:withQueue:isAsynchronous:</option>
  102. <option value="//api/name/setUserData:">&nbsp;&nbsp;&nbsp;&nbsp;- setUserData:</option>
  103. <option value="//api/name/socket4FD">&nbsp;&nbsp;&nbsp;&nbsp;- socket4FD</option>
  104. <option value="//api/name/socket6FD">&nbsp;&nbsp;&nbsp;&nbsp;- socket6FD</option>
  105. <option value="//api/name/socketFD">&nbsp;&nbsp;&nbsp;&nbsp;- socketFD</option>
  106. <option value="//api/name/synchronouslySetDelegate:">&nbsp;&nbsp;&nbsp;&nbsp;- synchronouslySetDelegate:</option>
  107. <option value="//api/name/synchronouslySetDelegate:delegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- synchronouslySetDelegate:delegateQueue:</option>
  108. <option value="//api/name/synchronouslySetDelegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- synchronouslySetDelegateQueue:</option>
  109. <option value="//api/name/userData">&nbsp;&nbsp;&nbsp;&nbsp;- userData</option>
  110. <option value="//api/name/writeStream">&nbsp;&nbsp;&nbsp;&nbsp;- writeStream</option>
  111. </select>
  112. </li>
  113. </ul>
  114. </header>
  115. <nav id="tocContainer" class="isShowingTOC">
  116. <ul id="toc" role="tree">
  117. <li role="treeitem"><span class="nodisclosure"></span><span class="sectionName"><a href="#overview">Overview</a></span></li>
  118. <li role="treeitem" id="task_treeitem"><span class="nodisclosure"></span><span class="sectionName"><a href="#tasks">Tasks</a></span><ul>
  119. </ul></li>
  120. <li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#class_methods">Class Methods</a></span><ul>
  121. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/familyFromAddress:">familyFromAddress:</a></span></li>
  122. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/getHost:port:family:fromAddress:">getHost:port:family:fromAddress:</a></span></li>
  123. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/getHost:port:fromAddress:">getHost:port:fromAddress:</a></span></li>
  124. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/hostFromAddress:">hostFromAddress:</a></span></li>
  125. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv4Address:">isIPv4Address:</a></span></li>
  126. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv6Address:">isIPv6Address:</a></span></li>
  127. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/portFromAddress:">portFromAddress:</a></span></li>
  128. </ul></li>
  129. <li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#instance_methods">Instance Methods</a></span><ul>
  130. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/beginReceiving:">beginReceiving:</a></span></li>
  131. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/bindToAddress:error:">bindToAddress:error:</a></span></li>
  132. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/bindToPort:error:">bindToPort:error:</a></span></li>
  133. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/bindToPort:interface:error:">bindToPort:interface:error:</a></span></li>
  134. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/close">close</a></span></li>
  135. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/closeAfterSending">closeAfterSending</a></span></li>
  136. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a></span></li>
  137. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a></span></li>
  138. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectedAddress">connectedAddress</a></span></li>
  139. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectedHost">connectedHost</a></span></li>
  140. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectedPort">connectedPort</a></span></li>
  141. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/delegate">delegate</a></span></li>
  142. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/delegateQueue">delegateQueue</a></span></li>
  143. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/enableBroadcast:error:">enableBroadcast:error:</a></span></li>
  144. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/getDelegate:delegateQueue:">getDelegate:delegateQueue:</a></span></li>
  145. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/init">init</a></span></li>
  146. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/initWithDelegate:delegateQueue:">initWithDelegate:delegateQueue:</a></span></li>
  147. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/initWithDelegate:delegateQueue:socketQueue:">initWithDelegate:delegateQueue:socketQueue:</a></span></li>
  148. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/initWithSocketQueue:">initWithSocketQueue:</a></span></li>
  149. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isClosed">isClosed</a></span></li>
  150. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isConnected">isConnected</a></span></li>
  151. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPVersionNeutral">isIPVersionNeutral</a></span></li>
  152. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv4">isIPv4</a></span></li>
  153. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv4Enabled">isIPv4Enabled</a></span></li>
  154. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv4Preferred">isIPv4Preferred</a></span></li>
  155. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv6">isIPv6</a></span></li>
  156. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv6Enabled">isIPv6Enabled</a></span></li>
  157. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv6Preferred">isIPv6Preferred</a></span></li>
  158. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/joinMulticastGroup:error:">joinMulticastGroup:error:</a></span></li>
  159. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/joinMulticastGroup:onInterface:error:">joinMulticastGroup:onInterface:error:</a></span></li>
  160. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/leaveMulticastGroup:error:">leaveMulticastGroup:error:</a></span></li>
  161. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/leaveMulticastGroup:onInterface:error:">leaveMulticastGroup:onInterface:error:</a></span></li>
  162. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localAddress">localAddress</a></span></li>
  163. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localAddress_IPv4">localAddress_IPv4</a></span></li>
  164. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localAddress_IPv6">localAddress_IPv6</a></span></li>
  165. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localHost">localHost</a></span></li>
  166. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localHost_IPv4">localHost_IPv4</a></span></li>
  167. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localHost_IPv6">localHost_IPv6</a></span></li>
  168. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localPort">localPort</a></span></li>
  169. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localPort_IPv4">localPort_IPv4</a></span></li>
  170. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localPort_IPv6">localPort_IPv6</a></span></li>
  171. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/maxReceiveIPv4BufferSize">maxReceiveIPv4BufferSize</a></span></li>
  172. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/maxReceiveIPv6BufferSize">maxReceiveIPv6BufferSize</a></span></li>
  173. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/pauseReceiving">pauseReceiving</a></span></li>
  174. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/performBlock:">performBlock:</a></span></li>
  175. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readStream">readStream</a></span></li>
  176. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/receiveOnce:">receiveOnce:</a></span></li>
  177. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/sendData:toAddress:withTimeout:tag:">sendData:toAddress:withTimeout:tag:</a></span></li>
  178. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/sendData:toHost:port:withTimeout:tag:">sendData:toHost:port:withTimeout:tag:</a></span></li>
  179. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/sendData:withTimeout:tag:">sendData:withTimeout:tag:</a></span></li>
  180. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setDelegate:">setDelegate:</a></span></li>
  181. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setDelegate:delegateQueue:">setDelegate:delegateQueue:</a></span></li>
  182. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setDelegateQueue:">setDelegateQueue:</a></span></li>
  183. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setIPVersionNeutral">setIPVersionNeutral</a></span></li>
  184. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setIPv4Enabled:">setIPv4Enabled:</a></span></li>
  185. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setIPv6Enabled:">setIPv6Enabled:</a></span></li>
  186. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setMaxReceiveIPv4BufferSize:">setMaxReceiveIPv4BufferSize:</a></span></li>
  187. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setMaxReceiveIPv6BufferSize:">setMaxReceiveIPv6BufferSize:</a></span></li>
  188. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setPreferIPv4">setPreferIPv4</a></span></li>
  189. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setPreferIPv6">setPreferIPv6</a></span></li>
  190. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setReceiveFilter:withQueue:">setReceiveFilter:withQueue:</a></span></li>
  191. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setReceiveFilter:withQueue:isAsynchronous:">setReceiveFilter:withQueue:isAsynchronous:</a></span></li>
  192. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setSendFilter:withQueue:">setSendFilter:withQueue:</a></span></li>
  193. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setSendFilter:withQueue:isAsynchronous:">setSendFilter:withQueue:isAsynchronous:</a></span></li>
  194. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setUserData:">setUserData:</a></span></li>
  195. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/socket4FD">socket4FD</a></span></li>
  196. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/socket6FD">socket6FD</a></span></li>
  197. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/socketFD">socketFD</a></span></li>
  198. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/synchronouslySetDelegate:">synchronouslySetDelegate:</a></span></li>
  199. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/synchronouslySetDelegate:delegateQueue:">synchronouslySetDelegate:delegateQueue:</a></span></li>
  200. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/synchronouslySetDelegateQueue:">synchronouslySetDelegateQueue:</a></span></li>
  201. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/userData">userData</a></span></li>
  202. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/writeStream">writeStream</a></span></li>
  203. </ul></li>
  204. </ul>
  205. </nav>
  206. <article>
  207. <div id="contents" class="isShowingTOC" role="main">
  208. <a title="GCDAsyncUdpSocket Class Reference" name="top"></a>
  209. <div class="main-navigation navigation-top">
  210. <ul>
  211. <li><a href="../index.html">Index</a></li>
  212. <li><a href="../hierarchy.html">Hierarchy</a></li>
  213. </ul>
  214. </div>
  215. <div id="header">
  216. <div class="section-header">
  217. <h1 class="title title-header">GCDAsyncUdpSocket Class Reference</h1>
  218. </div>
  219. </div>
  220. <div id="container">
  221. <div class="section section-specification"><table cellspacing="0"><tbody>
  222. <tr>
  223. <td class="specification-title">Inherits from</td>
  224. <td class="specification-value">NSObject</td>
  225. </tr><tr>
  226. <td class="specification-title">Declared in</td>
  227. <td class="specification-value">GCDAsyncUdpSocket.h</td>
  228. </tr>
  229. </tbody></table></div>
  230. <div class="section section-overview">
  231. <a title="Overview" name="overview"></a>
  232. <h2 class="subtitle subtitle-overview">Overview</h2>
  233. <p>You may optionally set a send filter for the socket.<br/>
  234. A filter can provide several interesting possibilities:</p>
  235. <ol>
  236. <li><p>Optional caching of resolved addresses for domain names.<br/>
  237. The cache could later be consulted, resulting in fewer system calls to getaddrinfo.</p></li>
  238. <li><p>Reusable modules of code for bandwidth monitoring.</p></li>
  239. <li><p>Sometimes traffic shapers are needed to simulate real world environments.<br/>
  240. A filter allows you to write custom code to simulate such environments.<br/>
  241. The ability to code this yourself is especially helpful when your simulated environment<br/>
  242. is more complicated than simple traffic shaping (e.g. simulating a cone port restricted router),<br/>
  243. or the system tools to handle this aren&rsquo;t available (e.g. on a mobile device).</p></li>
  244. </ol>
  245. </div>
  246. <div class="section section-tasks">
  247. <a title="Tasks" name="tasks"></a>
  248. <h2 class="subtitle subtitle-tasks">Tasks</h2>
  249. <ul class="task-list">
  250. <li>
  251. <span class="tooltip">
  252. <code><a href="#//api/name/init">&ndash;&nbsp;init</a></code>
  253. <span class="tooltip"><p>GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> uses the standard <a href="#//api/name/delegate">delegate</a> paradigm,<br/>
  254. but executes all <a href="#//api/name/delegate">delegate</a> callbacks on a given <a href="#//api/name/delegate">delegate</a> dispatch queue.<br/>
  255. This allows for maximum concurrency, while at the same time providing easy thread safety.</p></span>
  256. </span>
  257. </li><li>
  258. <span class="tooltip">
  259. <code><a href="#//api/name/initWithSocketQueue:">&ndash;&nbsp;initWithSocketQueue:</a></code>
  260. </span>
  261. </li><li>
  262. <span class="tooltip">
  263. <code><a href="#//api/name/initWithDelegate:delegateQueue:">&ndash;&nbsp;initWithDelegate:delegateQueue:</a></code>
  264. </span>
  265. </li><li>
  266. <span class="tooltip">
  267. <code><a href="#//api/name/initWithDelegate:delegateQueue:socketQueue:">&ndash;&nbsp;initWithDelegate:delegateQueue:socketQueue:</a></code>
  268. </span>
  269. </li><li>
  270. <span class="tooltip">
  271. <code><a href="#//api/name/delegate">&ndash;&nbsp;delegate</a></code>
  272. </span>
  273. </li><li>
  274. <span class="tooltip">
  275. <code><a href="#//api/name/setDelegate:">&ndash;&nbsp;setDelegate:</a></code>
  276. </span>
  277. </li><li>
  278. <span class="tooltip">
  279. <code><a href="#//api/name/synchronouslySetDelegate:">&ndash;&nbsp;synchronouslySetDelegate:</a></code>
  280. </span>
  281. </li><li>
  282. <span class="tooltip">
  283. <code><a href="#//api/name/delegateQueue">&ndash;&nbsp;delegateQueue</a></code>
  284. </span>
  285. </li><li>
  286. <span class="tooltip">
  287. <code><a href="#//api/name/setDelegateQueue:">&ndash;&nbsp;setDelegateQueue:</a></code>
  288. </span>
  289. </li><li>
  290. <span class="tooltip">
  291. <code><a href="#//api/name/synchronouslySetDelegateQueue:">&ndash;&nbsp;synchronouslySetDelegateQueue:</a></code>
  292. </span>
  293. </li><li>
  294. <span class="tooltip">
  295. <code><a href="#//api/name/getDelegate:delegateQueue:">&ndash;&nbsp;getDelegate:delegateQueue:</a></code>
  296. </span>
  297. </li><li>
  298. <span class="tooltip">
  299. <code><a href="#//api/name/setDelegate:delegateQueue:">&ndash;&nbsp;setDelegate:delegateQueue:</a></code>
  300. </span>
  301. </li><li>
  302. <span class="tooltip">
  303. <code><a href="#//api/name/synchronouslySetDelegate:delegateQueue:">&ndash;&nbsp;synchronouslySetDelegate:delegateQueue:</a></code>
  304. </span>
  305. </li><li>
  306. <span class="tooltip">
  307. <code><a href="#//api/name/isIPv4Enabled">&ndash;&nbsp;isIPv4Enabled</a></code>
  308. <span class="tooltip"><p>By default, both IPv4 and IPv6 are enabled.</p></span>
  309. </span>
  310. </li><li>
  311. <span class="tooltip">
  312. <code><a href="#//api/name/setIPv4Enabled:">&ndash;&nbsp;setIPv4Enabled:</a></code>
  313. </span>
  314. </li><li>
  315. <span class="tooltip">
  316. <code><a href="#//api/name/isIPv6Enabled">&ndash;&nbsp;isIPv6Enabled</a></code>
  317. </span>
  318. </li><li>
  319. <span class="tooltip">
  320. <code><a href="#//api/name/setIPv6Enabled:">&ndash;&nbsp;setIPv6Enabled:</a></code>
  321. </span>
  322. </li><li>
  323. <span class="tooltip">
  324. <code><a href="#//api/name/isIPv4Preferred">&ndash;&nbsp;isIPv4Preferred</a></code>
  325. </span>
  326. </li><li>
  327. <span class="tooltip">
  328. <code><a href="#//api/name/isIPv6Preferred">&ndash;&nbsp;isIPv6Preferred</a></code>
  329. </span>
  330. </li><li>
  331. <span class="tooltip">
  332. <code><a href="#//api/name/isIPVersionNeutral">&ndash;&nbsp;isIPVersionNeutral</a></code>
  333. </span>
  334. </li><li>
  335. <span class="tooltip">
  336. <code><a href="#//api/name/setPreferIPv4">&ndash;&nbsp;setPreferIPv4</a></code>
  337. </span>
  338. </li><li>
  339. <span class="tooltip">
  340. <code><a href="#//api/name/setPreferIPv6">&ndash;&nbsp;setPreferIPv6</a></code>
  341. </span>
  342. </li><li>
  343. <span class="tooltip">
  344. <code><a href="#//api/name/setIPVersionNeutral">&ndash;&nbsp;setIPVersionNeutral</a></code>
  345. </span>
  346. </li><li>
  347. <span class="tooltip">
  348. <code><a href="#//api/name/maxReceiveIPv4BufferSize">&ndash;&nbsp;maxReceiveIPv4BufferSize</a></code>
  349. <span class="tooltip"><p>Gets/Sets the maximum size of the buffer that will be allocated for receive operations.<br/>
  350. The default maximum size is 9216 bytes.</p></span>
  351. </span>
  352. </li><li>
  353. <span class="tooltip">
  354. <code><a href="#//api/name/setMaxReceiveIPv4BufferSize:">&ndash;&nbsp;setMaxReceiveIPv4BufferSize:</a></code>
  355. </span>
  356. </li><li>
  357. <span class="tooltip">
  358. <code><a href="#//api/name/maxReceiveIPv6BufferSize">&ndash;&nbsp;maxReceiveIPv6BufferSize</a></code>
  359. </span>
  360. </li><li>
  361. <span class="tooltip">
  362. <code><a href="#//api/name/setMaxReceiveIPv6BufferSize:">&ndash;&nbsp;setMaxReceiveIPv6BufferSize:</a></code>
  363. </span>
  364. </li><li>
  365. <span class="tooltip">
  366. <code><a href="#//api/name/userData">&ndash;&nbsp;userData</a></code>
  367. <span class="tooltip"><p>User data allows you to associate arbitrary information with the socket.<br/>
  368. This data is not used internally in any way.</p></span>
  369. </span>
  370. </li><li>
  371. <span class="tooltip">
  372. <code><a href="#//api/name/setUserData:">&ndash;&nbsp;setUserData:</a></code>
  373. </span>
  374. </li><li>
  375. <span class="tooltip">
  376. <code><a href="#//api/name/localAddress">&ndash;&nbsp;localAddress</a></code>
  377. <span class="tooltip"><p>Returns the local address info for the socket.</p></span>
  378. </span>
  379. </li><li>
  380. <span class="tooltip">
  381. <code><a href="#//api/name/localHost">&ndash;&nbsp;localHost</a></code>
  382. </span>
  383. </li><li>
  384. <span class="tooltip">
  385. <code><a href="#//api/name/localPort">&ndash;&nbsp;localPort</a></code>
  386. </span>
  387. </li><li>
  388. <span class="tooltip">
  389. <code><a href="#//api/name/localAddress_IPv4">&ndash;&nbsp;localAddress_IPv4</a></code>
  390. </span>
  391. </li><li>
  392. <span class="tooltip">
  393. <code><a href="#//api/name/localHost_IPv4">&ndash;&nbsp;localHost_IPv4</a></code>
  394. </span>
  395. </li><li>
  396. <span class="tooltip">
  397. <code><a href="#//api/name/localPort_IPv4">&ndash;&nbsp;localPort_IPv4</a></code>
  398. </span>
  399. </li><li>
  400. <span class="tooltip">
  401. <code><a href="#//api/name/localAddress_IPv6">&ndash;&nbsp;localAddress_IPv6</a></code>
  402. </span>
  403. </li><li>
  404. <span class="tooltip">
  405. <code><a href="#//api/name/localHost_IPv6">&ndash;&nbsp;localHost_IPv6</a></code>
  406. </span>
  407. </li><li>
  408. <span class="tooltip">
  409. <code><a href="#//api/name/localPort_IPv6">&ndash;&nbsp;localPort_IPv6</a></code>
  410. </span>
  411. </li><li>
  412. <span class="tooltip">
  413. <code><a href="#//api/name/connectedAddress">&ndash;&nbsp;connectedAddress</a></code>
  414. <span class="tooltip"><p>Returns the remote address info for the socket.</p></span>
  415. </span>
  416. </li><li>
  417. <span class="tooltip">
  418. <code><a href="#//api/name/connectedHost">&ndash;&nbsp;connectedHost</a></code>
  419. </span>
  420. </li><li>
  421. <span class="tooltip">
  422. <code><a href="#//api/name/connectedPort">&ndash;&nbsp;connectedPort</a></code>
  423. </span>
  424. </li><li>
  425. <span class="tooltip">
  426. <code><a href="#//api/name/isConnected">&ndash;&nbsp;isConnected</a></code>
  427. <span class="tooltip"><p>Returns whether or not this socket has been connected to a single host.<br/>
  428. By design, UDP is a connectionless protocol, and connecting is not needed.<br/>
  429. If connected, the socket will only be able to send/receive data to/from the connected host.</p></span>
  430. </span>
  431. </li><li>
  432. <span class="tooltip">
  433. <code><a href="#//api/name/isClosed">&ndash;&nbsp;isClosed</a></code>
  434. <span class="tooltip"><p>Returns whether or not this socket has been closed.<br/>
  435. The only way a socket can be closed is if you explicitly call one of the <a href="#//api/name/close">close</a> methods.</p></span>
  436. </span>
  437. </li><li>
  438. <span class="tooltip">
  439. <code><a href="#//api/name/isIPv4">&ndash;&nbsp;isIPv4</a></code>
  440. <span class="tooltip"><p>Returns whether or not this socket is IPv4.</p></span>
  441. </span>
  442. </li><li>
  443. <span class="tooltip">
  444. <code><a href="#//api/name/isIPv6">&ndash;&nbsp;isIPv6</a></code>
  445. <span class="tooltip"><p>Returns whether or not this socket is IPv6.</p></span>
  446. </span>
  447. </li><li>
  448. <span class="tooltip">
  449. <code><a href="#//api/name/bindToPort:error:">&ndash;&nbsp;bindToPort:error:</a></code>
  450. <span class="tooltip"><p>Binds the UDP socket to the given port.<br/>
  451. Binding should be done for server sockets that receive data prior to sending it.<br/>
  452. Client sockets can skip binding,<br/>
  453. as the OS will automatically assign the socket an available port when it starts sending data.</p></span>
  454. </span>
  455. </li><li>
  456. <span class="tooltip">
  457. <code><a href="#//api/name/bindToPort:interface:error:">&ndash;&nbsp;bindToPort:interface:error:</a></code>
  458. <span class="tooltip"><p>Binds the UDP socket to the given port and optional interface.<br/>
  459. Binding should be done for server sockets that receive data prior to sending it.<br/>
  460. Client sockets can skip binding,<br/>
  461. as the OS will automatically assign the socket an available port when it starts sending data.</p></span>
  462. </span>
  463. </li><li>
  464. <span class="tooltip">
  465. <code><a href="#//api/name/bindToAddress:error:">&ndash;&nbsp;bindToAddress:error:</a></code>
  466. <span class="tooltip"><p>Binds the UDP socket to the given address, specified as a sockaddr structure wrapped in a NSData object.</p></span>
  467. </span>
  468. </li><li>
  469. <span class="tooltip">
  470. <code><a href="#//api/name/connectToHost:onPort:error:">&ndash;&nbsp;connectToHost:onPort:error:</a></code>
  471. <span class="tooltip"><p>Connects the UDP socket to the given host and port.<br/>
  472. By design, UDP is a connectionless protocol, and connecting is not needed.</p></span>
  473. </span>
  474. </li><li>
  475. <span class="tooltip">
  476. <code><a href="#//api/name/connectToAddress:error:">&ndash;&nbsp;connectToAddress:error:</a></code>
  477. <span class="tooltip"><p>Connects the UDP socket to the given address, specified as a sockaddr structure wrapped in a NSData object.</p></span>
  478. </span>
  479. </li><li>
  480. <span class="tooltip">
  481. <code><a href="#//api/name/joinMulticastGroup:error:">&ndash;&nbsp;joinMulticastGroup:error:</a></code>
  482. <span class="tooltip"><p>Join multicast group.<br/>
  483. Group should be an IP address (eg @&ldquo;225.228.0.1&rdquo;).</p></span>
  484. </span>
  485. </li><li>
  486. <span class="tooltip">
  487. <code><a href="#//api/name/joinMulticastGroup:onInterface:error:">&ndash;&nbsp;joinMulticastGroup:onInterface:error:</a></code>
  488. <span class="tooltip"><p>Join multicast group.<br/>
  489. Group should be an IP address (eg @&ldquo;225.228.0.1&rdquo;).<br/>
  490. The interface may be a name (e.g. &ldquo;en1&rdquo; or &ldquo;lo0&rdquo;) or the corresponding IP address (e.g. &ldquo;192.168.4.35&rdquo;).</p></span>
  491. </span>
  492. </li><li>
  493. <span class="tooltip">
  494. <code><a href="#//api/name/leaveMulticastGroup:error:">&ndash;&nbsp;leaveMulticastGroup:error:</a></code>
  495. </span>
  496. </li><li>
  497. <span class="tooltip">
  498. <code><a href="#//api/name/leaveMulticastGroup:onInterface:error:">&ndash;&nbsp;leaveMulticastGroup:onInterface:error:</a></code>
  499. </span>
  500. </li><li>
  501. <span class="tooltip">
  502. <code><a href="#//api/name/enableBroadcast:error:">&ndash;&nbsp;enableBroadcast:error:</a></code>
  503. <span class="tooltip"><p>By default, the underlying socket in the OS will not allow you to send broadcast messages.<br/>
  504. In order to send broadcast messages, you need to enable this functionality in the socket.</p></span>
  505. </span>
  506. </li><li>
  507. <span class="tooltip">
  508. <code><a href="#//api/name/sendData:withTimeout:tag:">&ndash;&nbsp;sendData:withTimeout:tag:</a></code>
  509. <span class="tooltip"><p>Asynchronously sends the given data, with the given timeout and tag.</p></span>
  510. </span>
  511. </li><li>
  512. <span class="tooltip">
  513. <code><a href="#//api/name/sendData:toHost:port:withTimeout:tag:">&ndash;&nbsp;sendData:toHost:port:withTimeout:tag:</a></code>
  514. <span class="tooltip"><p>Asynchronously sends the given data, with the given timeout and tag, to the given host and port.</p></span>
  515. </span>
  516. </li><li>
  517. <span class="tooltip">
  518. <code><a href="#//api/name/sendData:toAddress:withTimeout:tag:">&ndash;&nbsp;sendData:toAddress:withTimeout:tag:</a></code>
  519. <span class="tooltip"><p>Asynchronously sends the given data, with the given timeout and tag, to the given address.</p></span>
  520. </span>
  521. </li><li>
  522. <span class="tooltip">
  523. <code><a href="#//api/name/setSendFilter:withQueue:">&ndash;&nbsp;setSendFilter:withQueue:</a></code>
  524. <span class="tooltip"><p>You may optionally set a send filter for the socket.<br/>
  525. A filter can provide several interesting possibilities:</p></span>
  526. </span>
  527. </li><li>
  528. <span class="tooltip">
  529. <code><a href="#//api/name/setSendFilter:withQueue:isAsynchronous:">&ndash;&nbsp;setSendFilter:withQueue:isAsynchronous:</a></code>
  530. <span class="tooltip"><p>The receive filter can be run via dispatch_async or dispatch_sync.<br/>
  531. Most typical situations call for asynchronous operation.</p></span>
  532. </span>
  533. </li><li>
  534. <span class="tooltip">
  535. <code><a href="#//api/name/receiveOnce:">&ndash;&nbsp;receiveOnce:</a></code>
  536. <span class="tooltip"><p>There are two modes of operation for receiving packets: one-at-a-time &amp; continuous.</p></span>
  537. </span>
  538. </li><li>
  539. <span class="tooltip">
  540. <code><a href="#//api/name/beginReceiving:">&ndash;&nbsp;beginReceiving:</a></code>
  541. <span class="tooltip"><p>There are two modes of operation for receiving packets: one-at-a-time &amp; continuous.</p></span>
  542. </span>
  543. </li><li>
  544. <span class="tooltip">
  545. <code><a href="#//api/name/pauseReceiving">&ndash;&nbsp;pauseReceiving</a></code>
  546. <span class="tooltip"><p>If the socket is currently receiving (beginReceiving has been called), this method pauses the receiving.<br/>
  547. That is, it won&rsquo;t read any more packets from the underlying OS socket until beginReceiving is called again.</p></span>
  548. </span>
  549. </li><li>
  550. <span class="tooltip">
  551. <code><a href="#//api/name/setReceiveFilter:withQueue:">&ndash;&nbsp;setReceiveFilter:withQueue:</a></code>
  552. <span class="tooltip"><p>You may optionally set a receive filter for the socket.<br/>
  553. This receive filter may be set to run in its own queue (independent of <a href="#//api/name/delegate">delegate</a> queue).</p></span>
  554. </span>
  555. </li><li>
  556. <span class="tooltip">
  557. <code><a href="#//api/name/setReceiveFilter:withQueue:isAsynchronous:">&ndash;&nbsp;setReceiveFilter:withQueue:isAsynchronous:</a></code>
  558. <span class="tooltip"><p>The receive filter can be run via dispatch_async or dispatch_sync.<br/>
  559. Most typical situations call for asynchronous operation.</p></span>
  560. </span>
  561. </li><li>
  562. <span class="tooltip">
  563. <code><a href="#//api/name/close">&ndash;&nbsp;close</a></code>
  564. <span class="tooltip"><p>Immediately closes the underlying socket.<br/>
  565. Any pending send operations are discarded.</p></span>
  566. </span>
  567. </li><li>
  568. <span class="tooltip">
  569. <code><a href="#//api/name/closeAfterSending">&ndash;&nbsp;closeAfterSending</a></code>
  570. <span class="tooltip"><p>Closes the underlying socket after all pending send operations have been sent.</p></span>
  571. </span>
  572. </li><li>
  573. <span class="tooltip">
  574. <code><a href="#//api/name/performBlock:">&ndash;&nbsp;performBlock:</a></code>
  575. <span class="tooltip"><p>It&rsquo;s not thread-safe to access certain variables from outside the socket&rsquo;s internal queue.</p></span>
  576. </span>
  577. </li><li>
  578. <span class="tooltip">
  579. <code><a href="#//api/name/socketFD">&ndash;&nbsp;socketFD</a></code>
  580. <span class="tooltip"><p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  581. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p></span>
  582. </span>
  583. </li><li>
  584. <span class="tooltip">
  585. <code><a href="#//api/name/socket4FD">&ndash;&nbsp;socket4FD</a></code>
  586. </span>
  587. </li><li>
  588. <span class="tooltip">
  589. <code><a href="#//api/name/socket6FD">&ndash;&nbsp;socket6FD</a></code>
  590. </span>
  591. </li><li>
  592. <span class="tooltip">
  593. <code><a href="#//api/name/readStream">&ndash;&nbsp;readStream</a></code>
  594. <span class="tooltip"><p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  595. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p></span>
  596. </span>
  597. </li><li>
  598. <span class="tooltip">
  599. <code><a href="#//api/name/writeStream">&ndash;&nbsp;writeStream</a></code>
  600. </span>
  601. </li><li>
  602. <span class="tooltip">
  603. <code><a href="#//api/name/hostFromAddress:">+&nbsp;hostFromAddress:</a></code>
  604. <span class="tooltip"><p>Extracting host/port/family information from raw address data.</p></span>
  605. </span>
  606. </li><li>
  607. <span class="tooltip">
  608. <code><a href="#//api/name/portFromAddress:">+&nbsp;portFromAddress:</a></code>
  609. </span>
  610. </li><li>
  611. <span class="tooltip">
  612. <code><a href="#//api/name/familyFromAddress:">+&nbsp;familyFromAddress:</a></code>
  613. </span>
  614. </li><li>
  615. <span class="tooltip">
  616. <code><a href="#//api/name/isIPv4Address:">+&nbsp;isIPv4Address:</a></code>
  617. </span>
  618. </li><li>
  619. <span class="tooltip">
  620. <code><a href="#//api/name/isIPv6Address:">+&nbsp;isIPv6Address:</a></code>
  621. </span>
  622. </li><li>
  623. <span class="tooltip">
  624. <code><a href="#//api/name/getHost:port:fromAddress:">+&nbsp;getHost:port:fromAddress:</a></code>
  625. </span>
  626. </li><li>
  627. <span class="tooltip">
  628. <code><a href="#//api/name/getHost:port:family:fromAddress:">+&nbsp;getHost:port:family:fromAddress:</a></code>
  629. </span>
  630. </li>
  631. </ul>
  632. </div>
  633. <div class="section section-methods">
  634. <a title="Class Methods" name="class_methods"></a>
  635. <h2 class="subtitle subtitle-methods">Class Methods</h2>
  636. <div class="section-method">
  637. <a name="//api/name/familyFromAddress:" title="familyFromAddress:"></a>
  638. <h3 class="subsubtitle method-title">familyFromAddress:</h3>
  639. <div class="method-subsection method-declaration"><code>+ (int)familyFromAddress:(NSData *)<em>address</em></code></div>
  640. </div>
  641. <div class="section-method">
  642. <a name="//api/name/getHost:port:family:fromAddress:" title="getHost:port:family:fromAddress:"></a>
  643. <h3 class="subsubtitle method-title">getHost:port:family:fromAddress:</h3>
  644. <div class="method-subsection method-declaration"><code>+ (BOOL)getHost:(NSString **)<em>hostPtr</em> port:(uint16_t *)<em>portPtr</em> family:(int *)<em>afPtr</em> fromAddress:(NSData *)<em>address</em></code></div>
  645. </div>
  646. <div class="section-method">
  647. <a name="//api/name/getHost:port:fromAddress:" title="getHost:port:fromAddress:"></a>
  648. <h3 class="subsubtitle method-title">getHost:port:fromAddress:</h3>
  649. <div class="method-subsection method-declaration"><code>+ (BOOL)getHost:(NSString **)<em>hostPtr</em> port:(uint16_t *)<em>portPtr</em> fromAddress:(NSData *)<em>address</em></code></div>
  650. </div>
  651. <div class="section-method">
  652. <a name="//api/name/hostFromAddress:" title="hostFromAddress:"></a>
  653. <h3 class="subsubtitle method-title">hostFromAddress:</h3>
  654. <div class="method-subsection brief-description">
  655. <p>Extracting host/port/family information from raw address data.</p>
  656. </div>
  657. <div class="method-subsection method-declaration"><code>+ (NSString *)hostFromAddress:(NSData *)<em>address</em></code></div>
  658. <div class="method-subsection discussion-section">
  659. <h4 class="method-subtitle">Discussion</h4>
  660. <p>Extracting host/port/family information from raw address data.</p>
  661. </div>
  662. <div class="method-subsection declared-in-section">
  663. <h4 class="method-subtitle">Declared In</h4>
  664. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  665. </div>
  666. </div>
  667. <div class="section-method">
  668. <a name="//api/name/isIPv4Address:" title="isIPv4Address:"></a>
  669. <h3 class="subsubtitle method-title">isIPv4Address:</h3>
  670. <div class="method-subsection method-declaration"><code>+ (BOOL)isIPv4Address:(NSData *)<em>address</em></code></div>
  671. </div>
  672. <div class="section-method">
  673. <a name="//api/name/isIPv6Address:" title="isIPv6Address:"></a>
  674. <h3 class="subsubtitle method-title">isIPv6Address:</h3>
  675. <div class="method-subsection method-declaration"><code>+ (BOOL)isIPv6Address:(NSData *)<em>address</em></code></div>
  676. </div>
  677. <div class="section-method">
  678. <a name="//api/name/portFromAddress:" title="portFromAddress:"></a>
  679. <h3 class="subsubtitle method-title">portFromAddress:</h3>
  680. <div class="method-subsection method-declaration"><code>+ (uint16_t)portFromAddress:(NSData *)<em>address</em></code></div>
  681. </div>
  682. </div>
  683. <div class="section section-methods">
  684. <a title="Instance Methods" name="instance_methods"></a>
  685. <h2 class="subtitle subtitle-methods">Instance Methods</h2>
  686. <div class="section-method">
  687. <a name="//api/name/beginReceiving:" title="beginReceiving:"></a>
  688. <h3 class="subsubtitle method-title">beginReceiving:</h3>
  689. <div class="method-subsection brief-description">
  690. <p>There are two modes of operation for receiving packets: one-at-a-time &amp; continuous.</p>
  691. </div>
  692. <div class="method-subsection method-declaration"><code>- (BOOL)beginReceiving:(NSError **)<em>errPtr</em></code></div>
  693. <div class="method-subsection discussion-section">
  694. <h4 class="method-subtitle">Discussion</h4>
  695. <p>There are two modes of operation for receiving packets: one-at-a-time &amp; continuous.</p>
  696. <p>In one-at-a-time mode, you call receiveOnce everytime your <a href="#//api/name/delegate">delegate</a> is ready to process an incoming udp packet.<br/>
  697. Receiving packets one-at-a-time may be better suited for implementing certain state machine code,<br/>
  698. where your state machine may not always be ready to process incoming packets.</p>
  699. <p>In continuous mode, the <a href="#//api/name/delegate">delegate</a> is invoked immediately everytime incoming udp packets are received.<br/>
  700. Receiving packets continuously is better suited to real-time streaming applications.</p>
  701. <p>You may switch back and forth between one-at-a-time mode and continuous mode.<br/>
  702. If the socket is currently in one-at-a-time mode, calling this method will switch it to continuous mode.</p>
  703. <p>For every received packet (not filtered by the optional receive filter),<br/>
  704. the <a href="#//api/name/delegate">delegate</a> method (udpSocket:didReceiveData:fromAddress:withFilterContext:) is invoked.</p>
  705. <p>If the socket is able to begin receiving packets, this method returns YES.<br/>
  706. Otherwise it returns NO, and sets the errPtr with appropriate error information.</p>
  707. <p>An example error:<br/>
  708. You created a udp socket to act as a server, and immediately called receive.<br/>
  709. You forgot to first bind the socket to a port number, and received a error with a message like:<br/>
  710. &ldquo;Must bind socket before you can receive data.&rdquo;</p>
  711. </div>
  712. <div class="method-subsection declared-in-section">
  713. <h4 class="method-subtitle">Declared In</h4>
  714. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  715. </div>
  716. </div>
  717. <div class="section-method">
  718. <a name="//api/name/bindToAddress:error:" title="bindToAddress:error:"></a>
  719. <h3 class="subsubtitle method-title">bindToAddress:error:</h3>
  720. <div class="method-subsection brief-description">
  721. <p>Binds the UDP socket to the given address, specified as a sockaddr structure wrapped in a NSData object.</p>
  722. </div>
  723. <div class="method-subsection method-declaration"><code>- (BOOL)bindToAddress:(NSData *)<em>localAddr</em> error:(NSError **)<em>errPtr</em></code></div>
  724. <div class="method-subsection discussion-section">
  725. <h4 class="method-subtitle">Discussion</h4>
  726. <p>Binds the UDP socket to the given address, specified as a sockaddr structure wrapped in a NSData object.</p>
  727. <p>If you have an existing struct sockaddr you can convert it to a NSData object like so:<br/>
  728. struct sockaddr sa -> NSData <em>dsa = [NSData dataWithBytes:&amp;remoteAddr length:remoteAddr.sa_len];<br/>
  729. struct sockaddr </em>sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len];</p>
  730. <p>Binding should be done for server sockets that receive data prior to sending it.<br/>
  731. Client sockets can skip binding,<br/>
  732. as the OS will automatically assign the socket an available port when it starts sending data.</p>
  733. <p>You cannot bind a socket after its been connected.<br/>
  734. You can only bind a socket once.<br/>
  735. You can still connect a socket (if desired) after binding.</p>
  736. <p>On success, returns YES.<br/>
  737. Otherwise returns NO, and sets errPtr. If you don&rsquo;t care about the error, you can pass NULL for errPtr.</p>
  738. </div>
  739. <div class="method-subsection declared-in-section">
  740. <h4 class="method-subtitle">Declared In</h4>
  741. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  742. </div>
  743. </div>
  744. <div class="section-method">
  745. <a name="//api/name/bindToPort:error:" title="bindToPort:error:"></a>
  746. <h3 class="subsubtitle method-title">bindToPort:error:</h3>
  747. <div class="method-subsection brief-description">
  748. <p>Binds the UDP socket to the given port.<br/>
  749. Binding should be done for server sockets that receive data prior to sending it.<br/>
  750. Client sockets can skip binding,<br/>
  751. as the OS will automatically assign the socket an available port when it starts sending data.</p>
  752. </div>
  753. <div class="method-subsection method-declaration"><code>- (BOOL)bindToPort:(uint16_t)<em>port</em> error:(NSError **)<em>errPtr</em></code></div>
  754. <div class="method-subsection discussion-section">
  755. <h4 class="method-subtitle">Discussion</h4>
  756. <p>Binds the UDP socket to the given port.<br/>
  757. Binding should be done for server sockets that receive data prior to sending it.<br/>
  758. Client sockets can skip binding,<br/>
  759. as the OS will automatically assign the socket an available port when it starts sending data.</p>
  760. <p>You may optionally pass a port number of zero to immediately bind the socket,<br/>
  761. yet still allow the OS to automatically assign an available port.</p>
  762. <p>You cannot bind a socket after its been connected.<br/>
  763. You can only bind a socket once.<br/>
  764. You can still connect a socket (if desired) after binding.</p>
  765. <p>On success, returns YES.<br/>
  766. Otherwise returns NO, and sets errPtr. If you don&rsquo;t care about the error, you can pass NULL for errPtr.</p>
  767. </div>
  768. <div class="method-subsection declared-in-section">
  769. <h4 class="method-subtitle">Declared In</h4>
  770. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  771. </div>
  772. </div>
  773. <div class="section-method">
  774. <a name="//api/name/bindToPort:interface:error:" title="bindToPort:interface:error:"></a>
  775. <h3 class="subsubtitle method-title">bindToPort:interface:error:</h3>
  776. <div class="method-subsection brief-description">
  777. <p>Binds the UDP socket to the given port and optional interface.<br/>
  778. Binding should be done for server sockets that receive data prior to sending it.<br/>
  779. Client sockets can skip binding,<br/>
  780. as the OS will automatically assign the socket an available port when it starts sending data.</p>
  781. </div>
  782. <div class="method-subsection method-declaration"><code>- (BOOL)bindToPort:(uint16_t)<em>port</em> interface:(NSString *)<em>interface</em> error:(NSError **)<em>errPtr</em></code></div>
  783. <div class="method-subsection discussion-section">
  784. <h4 class="method-subtitle">Discussion</h4>
  785. <p>Binds the UDP socket to the given port and optional interface.<br/>
  786. Binding should be done for server sockets that receive data prior to sending it.<br/>
  787. Client sockets can skip binding,<br/>
  788. as the OS will automatically assign the socket an available port when it starts sending data.</p>
  789. <p>You may optionally pass a port number of zero to immediately bind the socket,<br/>
  790. yet still allow the OS to automatically assign an available port.</p>
  791. <p>The interface may be a name (e.g. &ldquo;en1&rdquo; or &ldquo;lo0&rdquo;) or the corresponding IP address (e.g. &ldquo;192.168.4.35&rdquo;).<br/>
  792. You may also use the special strings &ldquo;localhost&rdquo; or &ldquo;loopback&rdquo; to specify that<br/>
  793. the socket only accept packets from the local machine.</p>
  794. <p>You cannot bind a socket after its been connected.<br/>
  795. You can only bind a socket once.<br/>
  796. You can still connect a socket (if desired) after binding.</p>
  797. <p>On success, returns YES.<br/>
  798. Otherwise returns NO, and sets errPtr. If you don&rsquo;t care about the error, you can pass NULL for errPtr.</p>
  799. </div>
  800. <div class="method-subsection declared-in-section">
  801. <h4 class="method-subtitle">Declared In</h4>
  802. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  803. </div>
  804. </div>
  805. <div class="section-method">
  806. <a name="//api/name/close" title="close"></a>
  807. <h3 class="subsubtitle method-title">close</h3>
  808. <div class="method-subsection brief-description">
  809. <p>Immediately closes the underlying socket.<br/>
  810. Any pending send operations are discarded.</p>
  811. </div>
  812. <div class="method-subsection method-declaration"><code>- (void)close</code></div>
  813. <div class="method-subsection discussion-section">
  814. <h4 class="method-subtitle">Discussion</h4>
  815. <p>Immediately closes the underlying socket.<br/>
  816. Any pending send operations are discarded.</p>
  817. <p>The GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> instance may optionally be used again.<br/>
  818. (it will setup/configure/use another unnderlying BSD socket).</p>
  819. </div>
  820. <div class="method-subsection declared-in-section">
  821. <h4 class="method-subtitle">Declared In</h4>
  822. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  823. </div>
  824. </div>
  825. <div class="section-method">
  826. <a name="//api/name/closeAfterSending" title="closeAfterSending"></a>
  827. <h3 class="subsubtitle method-title">closeAfterSending</h3>
  828. <div class="method-subsection brief-description">
  829. <p>Closes the underlying socket after all pending send operations have been sent.</p>
  830. </div>
  831. <div class="method-subsection method-declaration"><code>- (void)closeAfterSending</code></div>
  832. <div class="method-subsection discussion-section">
  833. <h4 class="method-subtitle">Discussion</h4>
  834. <p>Closes the underlying socket after all pending send operations have been sent.</p>
  835. <p>The GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> instance may optionally be used again.<br/>
  836. (it will setup/configure/use another unnderlying BSD socket).</p>
  837. </div>
  838. <div class="method-subsection declared-in-section">
  839. <h4 class="method-subtitle">Declared In</h4>
  840. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  841. </div>
  842. </div>
  843. <div class="section-method">
  844. <a name="//api/name/connectToAddress:error:" title="connectToAddress:error:"></a>
  845. <h3 class="subsubtitle method-title">connectToAddress:error:</h3>
  846. <div class="method-subsection brief-description">
  847. <p>Connects the UDP socket to the given address, specified as a sockaddr structure wrapped in a NSData object.</p>
  848. </div>
  849. <div class="method-subsection method-declaration"><code>- (BOOL)connectToAddress:(NSData *)<em>remoteAddr</em> error:(NSError **)<em>errPtr</em></code></div>
  850. <div class="method-subsection discussion-section">
  851. <h4 class="method-subtitle">Discussion</h4>
  852. <p>Connects the UDP socket to the given address, specified as a sockaddr structure wrapped in a NSData object.</p>
  853. <p>If you have an existing struct sockaddr you can convert it to a NSData object like so:<br/>
  854. struct sockaddr sa -> NSData <em>dsa = [NSData dataWithBytes:&amp;remoteAddr length:remoteAddr.sa_len];<br/>
  855. struct sockaddr </em>sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len];</p>
  856. <p>By design, UDP is a connectionless protocol, and connecting is not needed.</p>
  857. <p>Choosing to connect to a specific address has the following effect:<br/>
  858. - You will only be able to send data to the connected address.<br/>
  859. - You will only be able to receive data from the connected address.<br/>
  860. - You will receive ICMP messages that come from the connected address, such as &ldquo;connection refused&rdquo;.</p>
  861. <p>Connecting a UDP socket does not result in any communication on the socket.<br/>
  862. It simply changes the internal state of the socket.</p>
  863. <p>You cannot bind a socket after its been connected.<br/>
  864. You can only connect a socket once.</p>
  865. <p>On success, returns YES.<br/>
  866. Otherwise returns NO, and sets errPtr. If you don&rsquo;t care about the error, you can pass nil for errPtr.</p>
  867. <p>Note: Unlike the <a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a> method, this method does not require a DNS lookup.<br/>
  868. Thus when this method returns, the connection has either failed or fully completed.<br/>
  869. In other words, this method is synchronous, unlike the asynchronous connectToHost::: method.<br/>
  870. However, for compatibility and simplification of <a href="#//api/name/delegate">delegate</a> code, if this method returns YES<br/>
  871. then the corresponding <a href="#//api/name/delegate">delegate</a> method (udpSocket:didConnectToHost:port:) is still invoked.</p>
  872. </div>
  873. <div class="method-subsection declared-in-section">
  874. <h4 class="method-subtitle">Declared In</h4>
  875. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  876. </div>
  877. </div>
  878. <div class="section-method">
  879. <a name="//api/name/connectToHost:onPort:error:" title="connectToHost:onPort:error:"></a>
  880. <h3 class="subsubtitle method-title">connectToHost:onPort:error:</h3>
  881. <div class="method-subsection brief-description">
  882. <p>Connects the UDP socket to the given host and port.<br/>
  883. By design, UDP is a connectionless protocol, and connecting is not needed.</p>
  884. </div>
  885. <div class="method-subsection method-declaration"><code>- (BOOL)connectToHost:(NSString *)<em>host</em> onPort:(uint16_t)<em>port</em> error:(NSError **)<em>errPtr</em></code></div>
  886. <div class="method-subsection discussion-section">
  887. <h4 class="method-subtitle">Discussion</h4>
  888. <p>Connects the UDP socket to the given host and port.<br/>
  889. By design, UDP is a connectionless protocol, and connecting is not needed.</p>
  890. <p>Choosing to connect to a specific host/port has the following effect:<br/>
  891. - You will only be able to send data to the connected host/port.<br/>
  892. - You will only be able to receive data from the connected host/port.<br/>
  893. - You will receive ICMP messages that come from the connected host/port, such as &ldquo;connection refused&rdquo;.</p>
  894. <p>The actual process of connecting a UDP socket does not result in any communication on the socket.<br/>
  895. It simply changes the internal state of the socket.</p>
  896. <p>You cannot bind a socket after it has been connected.<br/>
  897. You can only connect a socket once.</p>
  898. <p>The host may be a domain name (e.g. &ldquo;deusty.com&rdquo;) or an IP address string (e.g. &ldquo;192.168.0.2&rdquo;).</p>
  899. <p>This method is asynchronous as it requires a DNS lookup to resolve the given host name.<br/>
  900. If an obvious error is detected, this method immediately returns NO and sets errPtr.<br/>
  901. If you don&rsquo;t care about the error, you can pass nil for errPtr.<br/>
  902. Otherwise, this method returns YES and begins the asynchronous connection process.<br/>
  903. The result of the asynchronous connection process will be reported via the <a href="#//api/name/delegate">delegate</a> methods.</p>
  904. </div>
  905. <div class="method-subsection declared-in-section">
  906. <h4 class="method-subtitle">Declared In</h4>
  907. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  908. </div>
  909. </div>
  910. <div class="section-method">
  911. <a name="//api/name/connectedAddress" title="connectedAddress"></a>
  912. <h3 class="subsubtitle method-title">connectedAddress</h3>
  913. <div class="method-subsection brief-description">
  914. <p>Returns the remote address info for the socket.</p>
  915. </div>
  916. <div class="method-subsection method-declaration"><code>- (NSData *)connectedAddress</code></div>
  917. <div class="method-subsection discussion-section">
  918. <h4 class="method-subtitle">Discussion</h4>
  919. <p>Returns the remote address info for the socket.</p>
  920. <p>The connectedAddress method returns a sockaddr structure wrapped in a NSData object.<br/>
  921. The <a href="#//api/name/connectedHost">connectedHost</a> method returns the human readable IP address as a string.</p>
  922. <p>Note: Since UDP is connectionless by design, connected address info<br/>
  923. will not be available unless the socket is explicitly connected to a remote host/port.<br/>
  924. If the socket is not connected, these methods will return nil / 0.</p>
  925. </div>
  926. <div class="method-subsection declared-in-section">
  927. <h4 class="method-subtitle">Declared In</h4>
  928. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  929. </div>
  930. </div>
  931. <div class="section-method">
  932. <a name="//api/name/connectedHost" title="connectedHost"></a>
  933. <h3 class="subsubtitle method-title">connectedHost</h3>
  934. <div class="method-subsection method-declaration"><code>- (NSString *)connectedHost</code></div>
  935. </div>
  936. <div class="section-method">
  937. <a name="//api/name/connectedPort" title="connectedPort"></a>
  938. <h3 class="subsubtitle method-title">connectedPort</h3>
  939. <div class="method-subsection method-declaration"><code>- (uint16_t)connectedPort</code></div>
  940. </div>
  941. <div class="section-method">
  942. <a name="//api/name/delegate" title="delegate"></a>
  943. <h3 class="subsubtitle method-title">delegate</h3>
  944. <div class="method-subsection method-declaration"><code>- (id)delegate</code></div>
  945. </div>
  946. <div class="section-method">
  947. <a name="//api/name/delegateQueue" title="delegateQueue"></a>
  948. <h3 class="subsubtitle method-title">delegateQueue</h3>
  949. <div class="method-subsection method-declaration"><code>- (dispatch_queue_t)delegateQueue</code></div>
  950. </div>
  951. <div class="section-method">
  952. <a name="//api/name/enableBroadcast:error:" title="enableBroadcast:error:"></a>
  953. <h3 class="subsubtitle method-title">enableBroadcast:error:</h3>
  954. <div class="method-subsection brief-description">
  955. <p>By default, the underlying socket in the OS will not allow you to send broadcast messages.<br/>
  956. In order to send broadcast messages, you need to enable this functionality in the socket.</p>
  957. </div>
  958. <div class="method-subsection method-declaration"><code>- (BOOL)enableBroadcast:(BOOL)<em>flag</em> error:(NSError **)<em>errPtr</em></code></div>
  959. <div class="method-subsection discussion-section">
  960. <h4 class="method-subtitle">Discussion</h4>
  961. <p>By default, the underlying socket in the OS will not allow you to send broadcast messages.<br/>
  962. In order to send broadcast messages, you need to enable this functionality in the socket.</p>
  963. <p>A broadcast is a UDP message to addresses like &ldquo;192.168.255.255&rdquo; or &ldquo;255.255.255.255&rdquo; that is<br/>
  964. delivered to every host on the network.<br/>
  965. The reason this is generally disabled by default (by the OS) is to prevent<br/>
  966. accidental broadcast messages from flooding the network.</p>
  967. </div>
  968. <div class="method-subsection declared-in-section">
  969. <h4 class="method-subtitle">Declared In</h4>
  970. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  971. </div>
  972. </div>
  973. <div class="section-method">
  974. <a name="//api/name/getDelegate:delegateQueue:" title="getDelegate:delegateQueue:"></a>
  975. <h3 class="subsubtitle method-title">getDelegate:delegateQueue:</h3>
  976. <div class="method-subsection method-declaration"><code>- (void)getDelegate:(id *)<em>delegatePtr</em> delegateQueue:(dispatch_queue_t *)<em>delegateQueuePtr</em></code></div>
  977. </div>
  978. <div class="section-method">
  979. <a name="//api/name/init" title="init"></a>
  980. <h3 class="subsubtitle method-title">init</h3>
  981. <div class="method-subsection brief-description">
  982. <p>GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> uses the standard <a href="#//api/name/delegate">delegate</a> paradigm,<br/>
  983. but executes all <a href="#//api/name/delegate">delegate</a> callbacks on a given <a href="#//api/name/delegate">delegate</a> dispatch queue.<br/>
  984. This allows for maximum concurrency, while at the same time providing easy thread safety.</p>
  985. </div>
  986. <div class="method-subsection method-declaration"><code>- (id)init</code></div>
  987. <div class="method-subsection discussion-section">
  988. <h4 class="method-subtitle">Discussion</h4>
  989. <p>GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> uses the standard <a href="#//api/name/delegate">delegate</a> paradigm,<br/>
  990. but executes all <a href="#//api/name/delegate">delegate</a> callbacks on a given <a href="#//api/name/delegate">delegate</a> dispatch queue.<br/>
  991. This allows for maximum concurrency, while at the same time providing easy thread safety.</p>
  992. <p>You MUST set a <a href="#//api/name/delegate">delegate</a> AND <a href="#//api/name/delegate">delegate</a> dispatch queue before attempting to<br/>
  993. use the socket, or you will get an error.</p>
  994. <p>The socket queue is optional.<br/>
  995. If you pass NULL, <a href="../Classes/GCDAsyncSocket.html">GCDAsyncSocket</a> will automatically create its own socket queue.<br/>
  996. If you choose to provide a socket queue, the socket queue must not be a concurrent queue.</p>
  997. <p>The <a href="#//api/name/delegate">delegate</a> queue and socket queue can optionally be the same.</p>
  998. </div>
  999. <div class="method-subsection declared-in-section">
  1000. <h4 class="method-subtitle">Declared In</h4>
  1001. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1002. </div>
  1003. </div>
  1004. <div class="section-method">
  1005. <a name="//api/name/initWithDelegate:delegateQueue:" title="initWithDelegate:delegateQueue:"></a>
  1006. <h3 class="subsubtitle method-title">initWithDelegate:delegateQueue:</h3>
  1007. <div class="method-subsection method-declaration"><code>- (id)initWithDelegate:(id)<em>aDelegate</em> delegateQueue:(dispatch_queue_t)<em>dq</em></code></div>
  1008. </div>
  1009. <div class="section-method">
  1010. <a name="//api/name/initWithDelegate:delegateQueue:socketQueue:" title="initWithDelegate:delegateQueue:socketQueue:"></a>
  1011. <h3 class="subsubtitle method-title">initWithDelegate:delegateQueue:socketQueue:</h3>
  1012. <div class="method-subsection method-declaration"><code>- (id)initWithDelegate:(id)<em>aDelegate</em> delegateQueue:(dispatch_queue_t)<em>dq</em> socketQueue:(dispatch_queue_t)<em>sq</em></code></div>
  1013. </div>
  1014. <div class="section-method">
  1015. <a name="//api/name/initWithSocketQueue:" title="initWithSocketQueue:"></a>
  1016. <h3 class="subsubtitle method-title">initWithSocketQueue:</h3>
  1017. <div class="method-subsection method-declaration"><code>- (id)initWithSocketQueue:(dispatch_queue_t)<em>sq</em></code></div>
  1018. </div>
  1019. <div class="section-method">
  1020. <a name="//api/name/isClosed" title="isClosed"></a>
  1021. <h3 class="subsubtitle method-title">isClosed</h3>
  1022. <div class="method-subsection brief-description">
  1023. <p>Returns whether or not this socket has been closed.<br/>
  1024. The only way a socket can be closed is if you explicitly call one of the <a href="#//api/name/close">close</a> methods.</p>
  1025. </div>
  1026. <div class="method-subsection method-declaration"><code>- (BOOL)isClosed</code></div>
  1027. <div class="method-subsection discussion-section">
  1028. <h4 class="method-subtitle">Discussion</h4>
  1029. <p>Returns whether or not this socket has been closed.<br/>
  1030. The only way a socket can be closed is if you explicitly call one of the <a href="#//api/name/close">close</a> methods.</p>
  1031. </div>
  1032. <div class="method-subsection declared-in-section">
  1033. <h4 class="method-subtitle">Declared In</h4>
  1034. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1035. </div>
  1036. </div>
  1037. <div class="section-method">
  1038. <a name="//api/name/isConnected" title="isConnected"></a>
  1039. <h3 class="subsubtitle method-title">isConnected</h3>
  1040. <div class="method-subsection brief-description">
  1041. <p>Returns whether or not this socket has been connected to a single host.<br/>
  1042. By design, UDP is a connectionless protocol, and connecting is not needed.<br/>
  1043. If connected, the socket will only be able to send/receive data to/from the connected host.</p>
  1044. </div>
  1045. <div class="method-subsection method-declaration"><code>- (BOOL)isConnected</code></div>
  1046. <div class="method-subsection discussion-section">
  1047. <h4 class="method-subtitle">Discussion</h4>
  1048. <p>Returns whether or not this socket has been connected to a single host.<br/>
  1049. By design, UDP is a connectionless protocol, and connecting is not needed.<br/>
  1050. If connected, the socket will only be able to send/receive data to/from the connected host.</p>
  1051. </div>
  1052. <div class="method-subsection declared-in-section">
  1053. <h4 class="method-subtitle">Declared In</h4>
  1054. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1055. </div>
  1056. </div>
  1057. <div class="section-method">
  1058. <a name="//api/name/isIPVersionNeutral" title="isIPVersionNeutral"></a>
  1059. <h3 class="subsubtitle method-title">isIPVersionNeutral</h3>
  1060. <div class="method-subsection method-declaration"><code>- (BOOL)isIPVersionNeutral</code></div>
  1061. </div>
  1062. <div class="section-method">
  1063. <a name="//api/name/isIPv4" title="isIPv4"></a>
  1064. <h3 class="subsubtitle method-title">isIPv4</h3>
  1065. <div class="method-subsection brief-description">
  1066. <p>Returns whether or not this socket is IPv4.</p>
  1067. </div>
  1068. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv4</code></div>
  1069. <div class="method-subsection discussion-section">
  1070. <h4 class="method-subtitle">Discussion</h4>
  1071. <p>Returns whether or not this socket is IPv4.</p>
  1072. <p>By default this will be true, unless:<br/>
  1073. - IPv4 is disabled (via <a href="#//api/name/setIPv4Enabled:">setIPv4Enabled:</a>)<br/>
  1074. - The socket is explicitly bound to an IPv6 address<br/>
  1075. - The socket is connected to an IPv6 address</p>
  1076. </div>
  1077. <div class="method-subsection declared-in-section">
  1078. <h4 class="method-subtitle">Declared In</h4>
  1079. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1080. </div>
  1081. </div>
  1082. <div class="section-method">
  1083. <a name="//api/name/isIPv4Enabled" title="isIPv4Enabled"></a>
  1084. <h3 class="subsubtitle method-title">isIPv4Enabled</h3>
  1085. <div class="method-subsection brief-description">
  1086. <p>By default, both IPv4 and IPv6 are enabled.</p>
  1087. </div>
  1088. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv4Enabled</code></div>
  1089. <div class="method-subsection discussion-section">
  1090. <h4 class="method-subtitle">Discussion</h4>
  1091. <p>By default, both IPv4 and IPv6 are enabled.</p>
  1092. <p>This means GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> automatically supports both protocols,<br/>
  1093. and can send to IPv4 or IPv6 addresses,<br/>
  1094. as well as receive over IPv4 and IPv6.</p>
  1095. <p>For operations that require DNS resolution, GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> supports both IPv4 and IPv6.<br/>
  1096. If a DNS lookup returns only IPv4 results, GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> will automatically use IPv4.<br/>
  1097. If a DNS lookup returns only IPv6 results, GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> will automatically use IPv6.<br/>
  1098. If a DNS lookup returns both IPv4 and IPv6 results, then the protocol used depends on the configured preference.<br/>
  1099. If IPv4 is preferred, then IPv4 is used.<br/>
  1100. If IPv6 is preferred, then IPv6 is used.<br/>
  1101. If neutral, then the first IP version in the resolved array will be used.</p>
  1102. <p>Starting with Mac OS X 10.7 Lion and iOS 5, the default IP preference is neutral.<br/>
  1103. On prior systems the default IP preference is IPv4.</p>
  1104. </div>
  1105. <div class="method-subsection declared-in-section">
  1106. <h4 class="method-subtitle">Declared In</h4>
  1107. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1108. </div>
  1109. </div>
  1110. <div class="section-method">
  1111. <a name="//api/name/isIPv4Preferred" title="isIPv4Preferred"></a>
  1112. <h3 class="subsubtitle method-title">isIPv4Preferred</h3>
  1113. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv4Preferred</code></div>
  1114. </div>
  1115. <div class="section-method">
  1116. <a name="//api/name/isIPv6" title="isIPv6"></a>
  1117. <h3 class="subsubtitle method-title">isIPv6</h3>
  1118. <div class="method-subsection brief-description">
  1119. <p>Returns whether or not this socket is IPv6.</p>
  1120. </div>
  1121. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv6</code></div>
  1122. <div class="method-subsection discussion-section">
  1123. <h4 class="method-subtitle">Discussion</h4>
  1124. <p>Returns whether or not this socket is IPv6.</p>
  1125. <p>By default this will be true, unless:<br/>
  1126. - IPv6 is disabled (via <a href="#//api/name/setIPv6Enabled:">setIPv6Enabled:</a>)<br/>
  1127. - The socket is explicitly bound to an IPv4 address<br/>
  1128. _ The socket is connected to an IPv4 address</p>
  1129. <p>This method will also return false on platforms that do not support IPv6.<br/>
  1130. Note: The iPhone does not currently support IPv6.</p>
  1131. </div>
  1132. <div class="method-subsection declared-in-section">
  1133. <h4 class="method-subtitle">Declared In</h4>
  1134. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1135. </div>
  1136. </div>
  1137. <div class="section-method">
  1138. <a name="//api/name/isIPv6Enabled" title="isIPv6Enabled"></a>
  1139. <h3 class="subsubtitle method-title">isIPv6Enabled</h3>
  1140. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv6Enabled</code></div>
  1141. </div>
  1142. <div class="section-method">
  1143. <a name="//api/name/isIPv6Preferred" title="isIPv6Preferred"></a>
  1144. <h3 class="subsubtitle method-title">isIPv6Preferred</h3>
  1145. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv6Preferred</code></div>
  1146. </div>
  1147. <div class="section-method">
  1148. <a name="//api/name/joinMulticastGroup:error:" title="joinMulticastGroup:error:"></a>
  1149. <h3 class="subsubtitle method-title">joinMulticastGroup:error:</h3>
  1150. <div class="method-subsection brief-description">
  1151. <p>Join multicast group.<br/>
  1152. Group should be an IP address (eg @&ldquo;225.228.0.1&rdquo;).</p>
  1153. </div>
  1154. <div class="method-subsection method-declaration"><code>- (BOOL)joinMulticastGroup:(NSString *)<em>group</em> error:(NSError **)<em>errPtr</em></code></div>
  1155. <div class="method-subsection discussion-section">
  1156. <h4 class="method-subtitle">Discussion</h4>
  1157. <p>Join multicast group.<br/>
  1158. Group should be an IP address (eg @&ldquo;225.228.0.1&rdquo;).</p>
  1159. <p>On success, returns YES.<br/>
  1160. Otherwise returns NO, and sets errPtr. If you don&rsquo;t care about the error, you can pass nil for errPtr.</p>
  1161. </div>
  1162. <div class="method-subsection declared-in-section">
  1163. <h4 class="method-subtitle">Declared In</h4>
  1164. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1165. </div>
  1166. </div>
  1167. <div class="section-method">
  1168. <a name="//api/name/joinMulticastGroup:onInterface:error:" title="joinMulticastGroup:onInterface:error:"></a>
  1169. <h3 class="subsubtitle method-title">joinMulticastGroup:onInterface:error:</h3>
  1170. <div class="method-subsection brief-description">
  1171. <p>Join multicast group.<br/>
  1172. Group should be an IP address (eg @&ldquo;225.228.0.1&rdquo;).<br/>
  1173. The interface may be a name (e.g. &ldquo;en1&rdquo; or &ldquo;lo0&rdquo;) or the corresponding IP address (e.g. &ldquo;192.168.4.35&rdquo;).</p>
  1174. </div>
  1175. <div class="method-subsection method-declaration"><code>- (BOOL)joinMulticastGroup:(NSString *)<em>group</em> onInterface:(NSString *)<em>interface</em> error:(NSError **)<em>errPtr</em></code></div>
  1176. <div class="method-subsection discussion-section">
  1177. <h4 class="method-subtitle">Discussion</h4>
  1178. <p>Join multicast group.<br/>
  1179. Group should be an IP address (eg @&ldquo;225.228.0.1&rdquo;).<br/>
  1180. The interface may be a name (e.g. &ldquo;en1&rdquo; or &ldquo;lo0&rdquo;) or the corresponding IP address (e.g. &ldquo;192.168.4.35&rdquo;).</p>
  1181. <p>On success, returns YES.<br/>
  1182. Otherwise returns NO, and sets errPtr. If you don&rsquo;t care about the error, you can pass nil for errPtr.</p>
  1183. </div>
  1184. <div class="method-subsection declared-in-section">
  1185. <h4 class="method-subtitle">Declared In</h4>
  1186. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1187. </div>
  1188. </div>
  1189. <div class="section-method">
  1190. <a name="//api/name/leaveMulticastGroup:error:" title="leaveMulticastGroup:error:"></a>
  1191. <h3 class="subsubtitle method-title">leaveMulticastGroup:error:</h3>
  1192. <div class="method-subsection method-declaration"><code>- (BOOL)leaveMulticastGroup:(NSString *)<em>group</em> error:(NSError **)<em>errPtr</em></code></div>
  1193. </div>
  1194. <div class="section-method">
  1195. <a name="//api/name/leaveMulticastGroup:onInterface:error:" title="leaveMulticastGroup:onInterface:error:"></a>
  1196. <h3 class="subsubtitle method-title">leaveMulticastGroup:onInterface:error:</h3>
  1197. <div class="method-subsection method-declaration"><code>- (BOOL)leaveMulticastGroup:(NSString *)<em>group</em> onInterface:(NSString *)<em>interface</em> error:(NSError **)<em>errPtr</em></code></div>
  1198. </div>
  1199. <div class="section-method">
  1200. <a name="//api/name/localAddress" title="localAddress"></a>
  1201. <h3 class="subsubtitle method-title">localAddress</h3>
  1202. <div class="method-subsection brief-description">
  1203. <p>Returns the local address info for the socket.</p>
  1204. </div>
  1205. <div class="method-subsection method-declaration"><code>- (NSData *)localAddress</code></div>
  1206. <div class="method-subsection discussion-section">
  1207. <h4 class="method-subtitle">Discussion</h4>
  1208. <p>Returns the local address info for the socket.</p>
  1209. <p>The localAddress method returns a sockaddr structure wrapped in a NSData object.<br/>
  1210. The <a href="#//api/name/localHost">localHost</a> method returns the human readable IP address as a string.</p>
  1211. <p>Note: Address info may not be available until after the socket has been binded, connected<br/>
  1212. or until after data has been sent.</p>
  1213. </div>
  1214. <div class="method-subsection declared-in-section">
  1215. <h4 class="method-subtitle">Declared In</h4>
  1216. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1217. </div>
  1218. </div>
  1219. <div class="section-method">
  1220. <a name="//api/name/localAddress_IPv4" title="localAddress_IPv4"></a>
  1221. <h3 class="subsubtitle method-title">localAddress_IPv4</h3>
  1222. <div class="method-subsection method-declaration"><code>- (NSData *)localAddress_IPv4</code></div>
  1223. </div>
  1224. <div class="section-method">
  1225. <a name="//api/name/localAddress_IPv6" title="localAddress_IPv6"></a>
  1226. <h3 class="subsubtitle method-title">localAddress_IPv6</h3>
  1227. <div class="method-subsection method-declaration"><code>- (NSData *)localAddress_IPv6</code></div>
  1228. </div>
  1229. <div class="section-method">
  1230. <a name="//api/name/localHost" title="localHost"></a>
  1231. <h3 class="subsubtitle method-title">localHost</h3>
  1232. <div class="method-subsection method-declaration"><code>- (NSString *)localHost</code></div>
  1233. </div>
  1234. <div class="section-method">
  1235. <a name="//api/name/localHost_IPv4" title="localHost_IPv4"></a>
  1236. <h3 class="subsubtitle method-title">localHost_IPv4</h3>
  1237. <div class="method-subsection method-declaration"><code>- (NSString *)localHost_IPv4</code></div>
  1238. </div>
  1239. <div class="section-method">
  1240. <a name="//api/name/localHost_IPv6" title="localHost_IPv6"></a>
  1241. <h3 class="subsubtitle method-title">localHost_IPv6</h3>
  1242. <div class="method-subsection method-declaration"><code>- (NSString *)localHost_IPv6</code></div>
  1243. </div>
  1244. <div class="section-method">
  1245. <a name="//api/name/localPort" title="localPort"></a>
  1246. <h3 class="subsubtitle method-title">localPort</h3>
  1247. <div class="method-subsection method-declaration"><code>- (uint16_t)localPort</code></div>
  1248. </div>
  1249. <div class="section-method">
  1250. <a name="//api/name/localPort_IPv4" title="localPort_IPv4"></a>
  1251. <h3 class="subsubtitle method-title">localPort_IPv4</h3>
  1252. <div class="method-subsection method-declaration"><code>- (uint16_t)localPort_IPv4</code></div>
  1253. </div>
  1254. <div class="section-method">
  1255. <a name="//api/name/localPort_IPv6" title="localPort_IPv6"></a>
  1256. <h3 class="subsubtitle method-title">localPort_IPv6</h3>
  1257. <div class="method-subsection method-declaration"><code>- (uint16_t)localPort_IPv6</code></div>
  1258. </div>
  1259. <div class="section-method">
  1260. <a name="//api/name/maxReceiveIPv4BufferSize" title="maxReceiveIPv4BufferSize"></a>
  1261. <h3 class="subsubtitle method-title">maxReceiveIPv4BufferSize</h3>
  1262. <div class="method-subsection brief-description">
  1263. <p>Gets/Sets the maximum size of the buffer that will be allocated for receive operations.<br/>
  1264. The default maximum size is 9216 bytes.</p>
  1265. </div>
  1266. <div class="method-subsection method-declaration"><code>- (uint16_t)maxReceiveIPv4BufferSize</code></div>
  1267. <div class="method-subsection discussion-section">
  1268. <h4 class="method-subtitle">Discussion</h4>
  1269. <p>Gets/Sets the maximum size of the buffer that will be allocated for receive operations.<br/>
  1270. The default maximum size is 9216 bytes.</p>
  1271. <p>The theoretical maximum size of any IPv4 UDP packet is UINT16_MAX = 65535.<br/>
  1272. The theoretical maximum size of any IPv6 UDP packet is UINT32_MAX = 4294967295.</p>
  1273. <p>Since the OS/GCD notifies us of the size of each received UDP packet,<br/>
  1274. the actual allocated buffer size for each packet is exact.<br/>
  1275. And in practice the size of UDP packets is generally much smaller than the max.<br/>
  1276. Indeed most protocols will send and receive packets of only a few bytes,<br/>
  1277. or will set a limit on the size of packets to prevent fragmentation in the IP layer.</p>
  1278. <p>If you set the buffer size too small, the sockets API in the OS will silently discard<br/>
  1279. any extra data, and you will not be notified of the error.</p>
  1280. </div>
  1281. <div class="method-subsection declared-in-section">
  1282. <h4 class="method-subtitle">Declared In</h4>
  1283. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1284. </div>
  1285. </div>
  1286. <div class="section-method">
  1287. <a name="//api/name/maxReceiveIPv6BufferSize" title="maxReceiveIPv6BufferSize"></a>
  1288. <h3 class="subsubtitle method-title">maxReceiveIPv6BufferSize</h3>
  1289. <div class="method-subsection method-declaration"><code>- (uint32_t)maxReceiveIPv6BufferSize</code></div>
  1290. </div>
  1291. <div class="section-method">
  1292. <a name="//api/name/pauseReceiving" title="pauseReceiving"></a>
  1293. <h3 class="subsubtitle method-title">pauseReceiving</h3>
  1294. <div class="method-subsection brief-description">
  1295. <p>If the socket is currently receiving (beginReceiving has been called), this method pauses the receiving.<br/>
  1296. That is, it won&rsquo;t read any more packets from the underlying OS socket until beginReceiving is called again.</p>
  1297. </div>
  1298. <div class="method-subsection method-declaration"><code>- (void)pauseReceiving</code></div>
  1299. <div class="method-subsection discussion-section">
  1300. <h4 class="method-subtitle">Discussion</h4>
  1301. <p>If the socket is currently receiving (beginReceiving has been called), this method pauses the receiving.<br/>
  1302. That is, it won&rsquo;t read any more packets from the underlying OS socket until beginReceiving is called again.</p>
  1303. <p>Important Note:<br/>
  1304. GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> may be running in parallel with your code.<br/>
  1305. That is, your <a href="#//api/name/delegate">delegate</a> is likely running on a separate thread/dispatch_queue.<br/>
  1306. When you invoke this method, GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> may have already dispatched <a href="#//api/name/delegate">delegate</a> methods to be invoked.<br/>
  1307. Thus, if those <a href="#//api/name/delegate">delegate</a> methods have already been dispatch_async&rsquo;d,<br/>
  1308. your didReceive <a href="#//api/name/delegate">delegate</a> method may still be invoked after this method has been called.<br/>
  1309. You should be aware of this, and program defensively.</p>
  1310. </div>
  1311. <div class="method-subsection declared-in-section">
  1312. <h4 class="method-subtitle">Declared In</h4>
  1313. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1314. </div>
  1315. </div>
  1316. <div class="section-method">
  1317. <a name="//api/name/performBlock:" title="performBlock:"></a>
  1318. <h3 class="subsubtitle method-title">performBlock:</h3>
  1319. <div class="method-subsection brief-description">
  1320. <p>It&rsquo;s not thread-safe to access certain variables from outside the socket&rsquo;s internal queue.</p>
  1321. </div>
  1322. <div class="method-subsection method-declaration"><code>- (void)performBlock:(dispatch_block_t)<em>block</em></code></div>
  1323. <div class="method-subsection discussion-section">
  1324. <h4 class="method-subtitle">Discussion</h4>
  1325. <p>It&rsquo;s not thread-safe to access certain variables from outside the socket&rsquo;s internal queue.</p>
  1326. <p>For example, the socket file descriptor.<br/>
  1327. File descriptors are simply integers which reference an index in the per-process file table.<br/>
  1328. However, when one requests a new file descriptor (by opening a file or socket),<br/>
  1329. the file descriptor returned is guaranteed to be the lowest numbered unused descriptor.<br/>
  1330. So if we&rsquo;re not careful, the following could be possible:</p>
  1331. <ul>
  1332. <li>Thread A invokes a method which returns the socket&rsquo;s file descriptor.</li>
  1333. <li>The socket is closed via the socket&rsquo;s internal queue on thread B.</li>
  1334. <li>Thread C opens a file, and subsequently receives the file descriptor that was previously the socket&rsquo;s FD.</li>
  1335. <li>Thread A is now accessing/altering the file instead of the socket.</li>
  1336. </ul>
  1337. <p>In addition to this, other variables are not actually objects,<br/>
  1338. and thus cannot be retained/released or even autoreleased.<br/>
  1339. An example is the sslContext, of type SSLContextRef, which is actually a malloc&rsquo;d struct.</p>
  1340. <p>Although there are internal variables that make it difficult to maintain thread-safety,<br/>
  1341. it is important to provide access to these variables<br/>
  1342. to ensure this class can be used in a wide array of environments.<br/>
  1343. This method helps to accomplish this by invoking the current block on the socket&rsquo;s internal queue.<br/>
  1344. The methods below can be invoked from within the block to access<br/>
  1345. those generally thread-unsafe internal variables in a thread-safe manner.<br/>
  1346. The given block will be invoked synchronously on the socket&rsquo;s internal queue.</p>
  1347. <p>If you save references to any protected variables and use them outside the block, you do so at your own peril.</p>
  1348. </div>
  1349. <div class="method-subsection declared-in-section">
  1350. <h4 class="method-subtitle">Declared In</h4>
  1351. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1352. </div>
  1353. </div>
  1354. <div class="section-method">
  1355. <a name="//api/name/readStream" title="readStream"></a>
  1356. <h3 class="subsubtitle method-title">readStream</h3>
  1357. <div class="method-subsection brief-description">
  1358. <p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1359. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1360. </div>
  1361. <div class="method-subsection method-declaration"><code>- (CFReadStreamRef)readStream</code></div>
  1362. <div class="method-subsection discussion-section">
  1363. <h4 class="method-subtitle">Discussion</h4>
  1364. <p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1365. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1366. <p>Returns (creating if necessary) a CFReadStream/CFWriteStream for the internal socket.</p>
  1367. <p>Generally GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> doesn&rsquo;t use CFStream. (It uses the faster GCD API&rsquo;s.)<br/>
  1368. However, if you need one for any reason,<br/>
  1369. these methods are a convenient way to get access to a safe instance of one.</p>
  1370. </div>
  1371. <div class="method-subsection declared-in-section">
  1372. <h4 class="method-subtitle">Declared In</h4>
  1373. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1374. </div>
  1375. </div>
  1376. <div class="section-method">
  1377. <a name="//api/name/receiveOnce:" title="receiveOnce:"></a>
  1378. <h3 class="subsubtitle method-title">receiveOnce:</h3>
  1379. <div class="method-subsection brief-description">
  1380. <p>There are two modes of operation for receiving packets: one-at-a-time &amp; continuous.</p>
  1381. </div>
  1382. <div class="method-subsection method-declaration"><code>- (BOOL)receiveOnce:(NSError **)<em>errPtr</em></code></div>
  1383. <div class="method-subsection discussion-section">
  1384. <h4 class="method-subtitle">Discussion</h4>
  1385. <p>There are two modes of operation for receiving packets: one-at-a-time &amp; continuous.</p>
  1386. <p>In one-at-a-time mode, you call receiveOnce everytime your <a href="#//api/name/delegate">delegate</a> is ready to process an incoming udp packet.<br/>
  1387. Receiving packets one-at-a-time may be better suited for implementing certain state machine code,<br/>
  1388. where your state machine may not always be ready to process incoming packets.</p>
  1389. <p>In continuous mode, the <a href="#//api/name/delegate">delegate</a> is invoked immediately everytime incoming udp packets are received.<br/>
  1390. Receiving packets continuously is better suited to real-time streaming applications.</p>
  1391. <p>You may switch back and forth between one-at-a-time mode and continuous mode.<br/>
  1392. If the socket is currently in continuous mode, calling this method will switch it to one-at-a-time mode.</p>
  1393. <p>When a packet is received (and not filtered by the optional receive filter),<br/>
  1394. the <a href="#//api/name/delegate">delegate</a> method (udpSocket:didReceiveData:fromAddress:withFilterContext:) is invoked.</p>
  1395. <p>If the socket is able to begin receiving packets, this method returns YES.<br/>
  1396. Otherwise it returns NO, and sets the errPtr with appropriate error information.</p>
  1397. <p>An example error:<br/>
  1398. You created a udp socket to act as a server, and immediately called receive.<br/>
  1399. You forgot to first bind the socket to a port number, and received a error with a message like:<br/>
  1400. &ldquo;Must bind socket before you can receive data.&rdquo;</p>
  1401. </div>
  1402. <div class="method-subsection declared-in-section">
  1403. <h4 class="method-subtitle">Declared In</h4>
  1404. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1405. </div>
  1406. </div>
  1407. <div class="section-method">
  1408. <a name="//api/name/sendData:toAddress:withTimeout:tag:" title="sendData:toAddress:withTimeout:tag:"></a>
  1409. <h3 class="subsubtitle method-title">sendData:toAddress:withTimeout:tag:</h3>
  1410. <div class="method-subsection brief-description">
  1411. <p>Asynchronously sends the given data, with the given timeout and tag, to the given address.</p>
  1412. </div>
  1413. <div class="method-subsection method-declaration"><code>- (void)sendData:(NSData *)<em>data</em> toAddress:(NSData *)<em>remoteAddr</em> withTimeout:(NSTimeInterval)<em>timeout</em> tag:(long)<em>tag</em></code></div>
  1414. <div class="method-subsection discussion-section">
  1415. <h4 class="method-subtitle">Discussion</h4>
  1416. <p>Asynchronously sends the given data, with the given timeout and tag, to the given address.</p>
  1417. <p>This method cannot be used with a connected socket.<br/>
  1418. Recall that connecting is optional for a UDP socket.<br/>
  1419. For connected sockets, data can only be sent to the connected address.<br/>
  1420. For non-connected sockets, the remote destination is specified for each packet.<br/>
  1421. For more information about optionally connecting udp sockets, see the documentation for the connect methods above.</p>
  1422. <p>@param data<br/>
  1423. The data to send.<br/>
  1424. If data is nil or zero-length, this method does nothing.<br/>
  1425. If passing NSMutableData, please read the thread-safety notice below.</p>
  1426. <p>@param address<br/>
  1427. The address to send the data to (specified as a sockaddr structure wrapped in a NSData object).</p>
  1428. <p>@param timeout<br/>
  1429. The timeout for the send opeartion.<br/>
  1430. If the timeout value is negative, the send operation will not use a timeout.</p>
  1431. <p>@param tag<br/>
  1432. The tag is for your convenience.<br/>
  1433. It is not sent or received over the socket in any manner what-so-ever.<br/>
  1434. It is reported back as a parameter in the udpSocket:didSendDataWithTag:<br/>
  1435. or udpSocket:didNotSendDataWithTag:dueToError: methods.<br/>
  1436. You can use it as an array index, state id, type constant, etc.</p>
  1437. <p>Thread-Safety Note:<br/>
  1438. If the given data parameter is mutable (NSMutableData) then you MUST NOT alter the data while<br/>
  1439. the socket is sending it. In other words, it&rsquo;s not safe to alter the data until after the <a href="#//api/name/delegate">delegate</a> method<br/>
  1440. udpSocket:didSendDataWithTag: or udpSocket:didNotSendDataWithTag:dueToError: is invoked signifying<br/>
  1441. that this particular send operation has completed.<br/>
  1442. This is due to the fact that GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> does NOT copy the data.<br/>
  1443. It simply retains it for performance reasons.<br/>
  1444. Often times, if NSMutableData is passed, it is because a request/response was built up in memory.<br/>
  1445. Copying this data adds an unwanted/unneeded overhead.<br/>
  1446. If you need to write data from an immutable buffer, and you need to alter the buffer before the socket<br/>
  1447. completes sending the bytes (which is NOT immediately after this method returns, but rather at a later time<br/>
  1448. when the <a href="#//api/name/delegate">delegate</a> method notifies you), then you should first copy the bytes, and pass the copy to this method.</p>
  1449. </div>
  1450. <div class="method-subsection declared-in-section">
  1451. <h4 class="method-subtitle">Declared In</h4>
  1452. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1453. </div>
  1454. </div>
  1455. <div class="section-method">
  1456. <a name="//api/name/sendData:toHost:port:withTimeout:tag:" title="sendData:toHost:port:withTimeout:tag:"></a>
  1457. <h3 class="subsubtitle method-title">sendData:toHost:port:withTimeout:tag:</h3>
  1458. <div class="method-subsection brief-description">
  1459. <p>Asynchronously sends the given data, with the given timeout and tag, to the given host and port.</p>
  1460. </div>
  1461. <div class="method-subsection method-declaration"><code>- (void)sendData:(NSData *)<em>data</em> toHost:(NSString *)<em>host</em> port:(uint16_t)<em>port</em> withTimeout:(NSTimeInterval)<em>timeout</em> tag:(long)<em>tag</em></code></div>
  1462. <div class="method-subsection discussion-section">
  1463. <h4 class="method-subtitle">Discussion</h4>
  1464. <p>Asynchronously sends the given data, with the given timeout and tag, to the given host and port.</p>
  1465. <p>This method cannot be used with a connected socket.<br/>
  1466. Recall that connecting is optional for a UDP socket.<br/>
  1467. For connected sockets, data can only be sent to the connected address.<br/>
  1468. For non-connected sockets, the remote destination is specified for each packet.<br/>
  1469. For more information about optionally connecting udp sockets, see the documentation for the connect methods above.</p>
  1470. <p>@param data<br/>
  1471. The data to send.<br/>
  1472. If data is nil or zero-length, this method does nothing.<br/>
  1473. If passing NSMutableData, please read the thread-safety notice below.</p>
  1474. <p>@param host<br/>
  1475. The destination to send the udp packet to.<br/>
  1476. May be specified as a domain name (e.g. &ldquo;deusty.com&rdquo;) or an IP address string (e.g. &ldquo;192.168.0.2&rdquo;).<br/>
  1477. You may also use the convenience strings of &ldquo;loopback&rdquo; or &ldquo;localhost&rdquo;.</p>
  1478. <p>@param port<br/>
  1479. The port of the host to send to.</p>
  1480. <p>@param timeout<br/>
  1481. The timeout for the send opeartion.<br/>
  1482. If the timeout value is negative, the send operation will not use a timeout.</p>
  1483. <p>@param tag<br/>
  1484. The tag is for your convenience.<br/>
  1485. It is not sent or received over the socket in any manner what-so-ever.<br/>
  1486. It is reported back as a parameter in the udpSocket:didSendDataWithTag:<br/>
  1487. or udpSocket:didNotSendDataWithTag:dueToError: methods.<br/>
  1488. You can use it as an array index, state id, type constant, etc.</p>
  1489. <p>Thread-Safety Note:<br/>
  1490. If the given data parameter is mutable (NSMutableData) then you MUST NOT alter the data while<br/>
  1491. the socket is sending it. In other words, it&rsquo;s not safe to alter the data until after the <a href="#//api/name/delegate">delegate</a> method<br/>
  1492. udpSocket:didSendDataWithTag: or udpSocket:didNotSendDataWithTag:dueToError: is invoked signifying<br/>
  1493. that this particular send operation has completed.<br/>
  1494. This is due to the fact that GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> does NOT copy the data.<br/>
  1495. It simply retains it for performance reasons.<br/>
  1496. Often times, if NSMutableData is passed, it is because a request/response was built up in memory.<br/>
  1497. Copying this data adds an unwanted/unneeded overhead.<br/>
  1498. If you need to write data from an immutable buffer, and you need to alter the buffer before the socket<br/>
  1499. completes sending the bytes (which is NOT immediately after this method returns, but rather at a later time<br/>
  1500. when the <a href="#//api/name/delegate">delegate</a> method notifies you), then you should first copy the bytes, and pass the copy to this method.</p>
  1501. </div>
  1502. <div class="method-subsection declared-in-section">
  1503. <h4 class="method-subtitle">Declared In</h4>
  1504. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1505. </div>
  1506. </div>
  1507. <div class="section-method">
  1508. <a name="//api/name/sendData:withTimeout:tag:" title="sendData:withTimeout:tag:"></a>
  1509. <h3 class="subsubtitle method-title">sendData:withTimeout:tag:</h3>
  1510. <div class="method-subsection brief-description">
  1511. <p>Asynchronously sends the given data, with the given timeout and tag.</p>
  1512. </div>
  1513. <div class="method-subsection method-declaration"><code>- (void)sendData:(NSData *)<em>data</em> withTimeout:(NSTimeInterval)<em>timeout</em> tag:(long)<em>tag</em></code></div>
  1514. <div class="method-subsection discussion-section">
  1515. <h4 class="method-subtitle">Discussion</h4>
  1516. <p>Asynchronously sends the given data, with the given timeout and tag.</p>
  1517. <p>This method may only be used with a connected socket.<br/>
  1518. Recall that connecting is optional for a UDP socket.<br/>
  1519. For connected sockets, data can only be sent to the connected address.<br/>
  1520. For non-connected sockets, the remote destination is specified for each packet.<br/>
  1521. For more information about optionally connecting udp sockets, see the documentation for the connect methods above.</p>
  1522. <p>@param data<br/>
  1523. The data to send.<br/>
  1524. If data is nil or zero-length, this method does nothing.<br/>
  1525. If passing NSMutableData, please read the thread-safety notice below.</p>
  1526. <p>@param timeout<br/>
  1527. The timeout for the send opeartion.<br/>
  1528. If the timeout value is negative, the send operation will not use a timeout.</p>
  1529. <p>@param tag<br/>
  1530. The tag is for your convenience.<br/>
  1531. It is not sent or received over the socket in any manner what-so-ever.<br/>
  1532. It is reported back as a parameter in the udpSocket:didSendDataWithTag:<br/>
  1533. or udpSocket:didNotSendDataWithTag:dueToError: methods.<br/>
  1534. You can use it as an array index, state id, type constant, etc.</p>
  1535. <p>Thread-Safety Note:<br/>
  1536. If the given data parameter is mutable (NSMutableData) then you MUST NOT alter the data while<br/>
  1537. the socket is sending it. In other words, it&rsquo;s not safe to alter the data until after the <a href="#//api/name/delegate">delegate</a> method<br/>
  1538. udpSocket:didSendDataWithTag: or udpSocket:didNotSendDataWithTag:dueToError: is invoked signifying<br/>
  1539. that this particular send operation has completed.<br/>
  1540. This is due to the fact that GCD<a href="../Classes/AsyncUdpSocket.html">AsyncUdpSocket</a> does NOT copy the data.<br/>
  1541. It simply retains it for performance reasons.<br/>
  1542. Often times, if NSMutableData is passed, it is because a request/response was built up in memory.<br/>
  1543. Copying this data adds an unwanted/unneeded overhead.<br/>
  1544. If you need to write data from an immutable buffer, and you need to alter the buffer before the socket<br/>
  1545. completes sending the bytes (which is NOT immediately after this method returns, but rather at a later time<br/>
  1546. when the <a href="#//api/name/delegate">delegate</a> method notifies you), then you should first copy the bytes, and pass the copy to this method.</p>
  1547. </div>
  1548. <div class="method-subsection declared-in-section">
  1549. <h4 class="method-subtitle">Declared In</h4>
  1550. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1551. </div>
  1552. </div>
  1553. <div class="section-method">
  1554. <a name="//api/name/setDelegate:" title="setDelegate:"></a>
  1555. <h3 class="subsubtitle method-title">setDelegate:</h3>
  1556. <div class="method-subsection method-declaration"><code>- (void)setDelegate:(id)<em>delegate</em></code></div>
  1557. </div>
  1558. <div class="section-method">
  1559. <a name="//api/name/setDelegate:delegateQueue:" title="setDelegate:delegateQueue:"></a>
  1560. <h3 class="subsubtitle method-title">setDelegate:delegateQueue:</h3>
  1561. <div class="method-subsection method-declaration"><code>- (void)setDelegate:(id)<em>delegate</em> delegateQueue:(dispatch_queue_t)<em>delegateQueue</em></code></div>
  1562. </div>
  1563. <div class="section-method">
  1564. <a name="//api/name/setDelegateQueue:" title="setDelegateQueue:"></a>
  1565. <h3 class="subsubtitle method-title">setDelegateQueue:</h3>
  1566. <div class="method-subsection method-declaration"><code>- (void)setDelegateQueue:(dispatch_queue_t)<em>delegateQueue</em></code></div>
  1567. </div>
  1568. <div class="section-method">
  1569. <a name="//api/name/setIPVersionNeutral" title="setIPVersionNeutral"></a>
  1570. <h3 class="subsubtitle method-title">setIPVersionNeutral</h3>
  1571. <div class="method-subsection method-declaration"><code>- (void)setIPVersionNeutral</code></div>
  1572. </div>
  1573. <div class="section-method">
  1574. <a name="//api/name/setIPv4Enabled:" title="setIPv4Enabled:"></a>
  1575. <h3 class="subsubtitle method-title">setIPv4Enabled:</h3>
  1576. <div class="method-subsection method-declaration"><code>- (void)setIPv4Enabled:(BOOL)<em>flag</em></code></div>
  1577. </div>
  1578. <div class="section-method">
  1579. <a name="//api/name/setIPv6Enabled:" title="setIPv6Enabled:"></a>
  1580. <h3 class="subsubtitle method-title">setIPv6Enabled:</h3>
  1581. <div class="method-subsection method-declaration"><code>- (void)setIPv6Enabled:(BOOL)<em>flag</em></code></div>
  1582. </div>
  1583. <div class="section-method">
  1584. <a name="//api/name/setMaxReceiveIPv4BufferSize:" title="setMaxReceiveIPv4BufferSize:"></a>
  1585. <h3 class="subsubtitle method-title">setMaxReceiveIPv4BufferSize:</h3>
  1586. <div class="method-subsection method-declaration"><code>- (void)setMaxReceiveIPv4BufferSize:(uint16_t)<em>max</em></code></div>
  1587. </div>
  1588. <div class="section-method">
  1589. <a name="//api/name/setMaxReceiveIPv6BufferSize:" title="setMaxReceiveIPv6BufferSize:"></a>
  1590. <h3 class="subsubtitle method-title">setMaxReceiveIPv6BufferSize:</h3>
  1591. <div class="method-subsection method-declaration"><code>- (void)setMaxReceiveIPv6BufferSize:(uint32_t)<em>max</em></code></div>
  1592. </div>
  1593. <div class="section-method">
  1594. <a name="//api/name/setPreferIPv4" title="setPreferIPv4"></a>
  1595. <h3 class="subsubtitle method-title">setPreferIPv4</h3>
  1596. <div class="method-subsection method-declaration"><code>- (void)setPreferIPv4</code></div>
  1597. </div>
  1598. <div class="section-method">
  1599. <a name="//api/name/setPreferIPv6" title="setPreferIPv6"></a>
  1600. <h3 class="subsubtitle method-title">setPreferIPv6</h3>
  1601. <div class="method-subsection method-declaration"><code>- (void)setPreferIPv6</code></div>
  1602. </div>
  1603. <div class="section-method">
  1604. <a name="//api/name/setReceiveFilter:withQueue:" title="setReceiveFilter:withQueue:"></a>
  1605. <h3 class="subsubtitle method-title">setReceiveFilter:withQueue:</h3>
  1606. <div class="method-subsection brief-description">
  1607. <p>You may optionally set a receive filter for the socket.<br/>
  1608. This receive filter may be set to run in its own queue (independent of <a href="#//api/name/delegate">delegate</a> queue).</p>
  1609. </div>
  1610. <div class="method-subsection method-declaration"><code>- (void)setReceiveFilter:(GCDAsyncUdpSocketReceiveFilterBlock)<em>filterBlock</em> withQueue:(dispatch_queue_t)<em>filterQueue</em></code></div>
  1611. <div class="method-subsection discussion-section">
  1612. <h4 class="method-subtitle">Discussion</h4>
  1613. <p>You may optionally set a receive filter for the socket.<br/>
  1614. This receive filter may be set to run in its own queue (independent of <a href="#//api/name/delegate">delegate</a> queue).</p>
  1615. <p>A filter can provide several useful features.</p>
  1616. <ol>
  1617. <li><p>Many times udp packets need to be parsed.<br/>
  1618. Since the filter can run in its own independent queue, you can parallelize this parsing quite easily.<br/>
  1619. The end result is a parallel socket io, datagram parsing, and packet processing.</p></li>
  1620. <li><p>Many times udp packets are discarded because they are duplicate/unneeded/unsolicited.<br/>
  1621. The filter can prevent such packets from arriving at the <a href="#//api/name/delegate">delegate</a>.<br/>
  1622. And because the filter can run in its own independent queue, this doesn&rsquo;t slow down the <a href="#//api/name/delegate">delegate</a>.</p></li>
  1623. <li><p>Since the udp protocol does not guarantee delivery, udp packets may be lost.<br/>
  1624. Many protocols built atop udp thus provide various resend/re-request algorithms.<br/>
  1625. This sometimes results in duplicate packets arriving.<br/>
  1626. A filter may allow you to architect the duplicate detection code to run in parallel to normal processing.</p></li>
  1627. <li><p>Since the udp socket may be connectionless, its possible for unsolicited packets to arrive.<br/>
  1628. Such packets need to be ignored.</p></li>
  1629. <li><p>Sometimes traffic shapers are needed to simulate real world environments.<br/>
  1630. A filter allows you to write custom code to simulate such environments.<br/>
  1631. The ability to code this yourself is especially helpful when your simulated environment<br/>
  1632. is more complicated than simple traffic shaping (e.g. simulating a cone port restricted router),<br/>
  1633. or the system tools to handle this aren&rsquo;t available (e.g. on a mobile device).</p></li>
  1634. </ol>
  1635. <p>Example:</p>
  1636. <p>GCDAsyncUdpSocketReceiveFilterBlock filter = ^BOOL (NSData <em>data, NSData </em>address, id *context) {</p>
  1637. <p>MyProtocolMessage *msg = [MyProtocol parseMessage:data];</p>
  1638. <p>*context = response;<br/>
  1639. return (response != nil);<br/>
  1640. };<br/>
  1641. [udpSocket setReceiveFilter:filter withQueue:myParsingQueue];</p>
  1642. <p>For more information about GCDAsyncUdpSocketReceiveFilterBlock, see the documentation for its typedef.<br/>
  1643. To remove a previously set filter, invoke this method and pass a nil filterBlock and NULL filterQueue.</p>
  1644. <p>Note: This method invokes <a href="#//api/name/setReceiveFilter:withQueue:isAsynchronous:">setReceiveFilter:withQueue:isAsynchronous:</a> (documented below),<br/>
  1645. passing YES for the isAsynchronous parameter.</p>
  1646. </div>
  1647. <div class="method-subsection declared-in-section">
  1648. <h4 class="method-subtitle">Declared In</h4>
  1649. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1650. </div>
  1651. </div>
  1652. <div class="section-method">
  1653. <a name="//api/name/setReceiveFilter:withQueue:isAsynchronous:" title="setReceiveFilter:withQueue:isAsynchronous:"></a>
  1654. <h3 class="subsubtitle method-title">setReceiveFilter:withQueue:isAsynchronous:</h3>
  1655. <div class="method-subsection brief-description">
  1656. <p>The receive filter can be run via dispatch_async or dispatch_sync.<br/>
  1657. Most typical situations call for asynchronous operation.</p>
  1658. </div>
  1659. <div class="method-subsection method-declaration"><code>- (void)setReceiveFilter:(GCDAsyncUdpSocketReceiveFilterBlock)<em>filterBlock</em> withQueue:(dispatch_queue_t)<em>filterQueue</em> isAsynchronous:(BOOL)<em>isAsynchronous</em></code></div>
  1660. <div class="method-subsection discussion-section">
  1661. <h4 class="method-subtitle">Discussion</h4>
  1662. <p>The receive filter can be run via dispatch_async or dispatch_sync.<br/>
  1663. Most typical situations call for asynchronous operation.</p>
  1664. <p>However, there are a few situations in which synchronous operation is preferred.<br/>
  1665. Such is the case when the filter is extremely minimal and fast.<br/>
  1666. This is because dispatch_sync is faster than dispatch_async.</p>
  1667. <p>If you choose synchronous operation, be aware of possible deadlock conditions.<br/>
  1668. Since the socket queue is executing your block via dispatch_sync,<br/>
  1669. then you cannot perform any tasks which may invoke dispatch_sync on the socket queue.<br/>
  1670. For example, you can&rsquo;t query properties on the socket.</p>
  1671. </div>
  1672. <div class="method-subsection declared-in-section">
  1673. <h4 class="method-subtitle">Declared In</h4>
  1674. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1675. </div>
  1676. </div>
  1677. <div class="section-method">
  1678. <a name="//api/name/setSendFilter:withQueue:" title="setSendFilter:withQueue:"></a>
  1679. <h3 class="subsubtitle method-title">setSendFilter:withQueue:</h3>
  1680. <div class="method-subsection brief-description">
  1681. <p>You may optionally set a send filter for the socket.<br/>
  1682. A filter can provide several interesting possibilities:</p>
  1683. </div>
  1684. <div class="method-subsection method-declaration"><code>- (void)setSendFilter:(GCDAsyncUdpSocketSendFilterBlock)<em>filterBlock</em> withQueue:(dispatch_queue_t)<em>filterQueue</em></code></div>
  1685. <div class="method-subsection discussion-section">
  1686. <h4 class="method-subtitle">Discussion</h4>
  1687. <p>You may optionally set a send filter for the socket.<br/>
  1688. A filter can provide several interesting possibilities:</p>
  1689. <ol>
  1690. <li><p>Optional caching of resolved addresses for domain names.<br/>
  1691. The cache could later be consulted, resulting in fewer system calls to getaddrinfo.</p></li>
  1692. <li><p>Reusable modules of code for bandwidth monitoring.</p></li>
  1693. <li><p>Sometimes traffic shapers are needed to simulate real world environments.<br/>
  1694. A filter allows you to write custom code to simulate such environments.<br/>
  1695. The ability to code this yourself is especially helpful when your simulated environment<br/>
  1696. is more complicated than simple traffic shaping (e.g. simulating a cone port restricted router),<br/>
  1697. or the system tools to handle this aren&rsquo;t available (e.g. on a mobile device).</p></li>
  1698. </ol>
  1699. <p>For more information about GCDAsyncUdpSocketSendFilterBlock, see the documentation for its typedef.<br/>
  1700. To remove a previously set filter, invoke this method and pass a nil filterBlock and NULL filterQueue.</p>
  1701. <p>Note: This method invokes <a href="#//api/name/setSendFilter:withQueue:isAsynchronous:">setSendFilter:withQueue:isAsynchronous:</a> (documented below),<br/>
  1702. passing YES for the isAsynchronous parameter.</p>
  1703. </div>
  1704. <div class="method-subsection declared-in-section">
  1705. <h4 class="method-subtitle">Declared In</h4>
  1706. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1707. </div>
  1708. </div>
  1709. <div class="section-method">
  1710. <a name="//api/name/setSendFilter:withQueue:isAsynchronous:" title="setSendFilter:withQueue:isAsynchronous:"></a>
  1711. <h3 class="subsubtitle method-title">setSendFilter:withQueue:isAsynchronous:</h3>
  1712. <div class="method-subsection brief-description">
  1713. <p>The receive filter can be run via dispatch_async or dispatch_sync.<br/>
  1714. Most typical situations call for asynchronous operation.</p>
  1715. </div>
  1716. <div class="method-subsection method-declaration"><code>- (void)setSendFilter:(GCDAsyncUdpSocketSendFilterBlock)<em>filterBlock</em> withQueue:(dispatch_queue_t)<em>filterQueue</em> isAsynchronous:(BOOL)<em>isAsynchronous</em></code></div>
  1717. <div class="method-subsection discussion-section">
  1718. <h4 class="method-subtitle">Discussion</h4>
  1719. <p>The receive filter can be run via dispatch_async or dispatch_sync.<br/>
  1720. Most typical situations call for asynchronous operation.</p>
  1721. <p>However, there are a few situations in which synchronous operation is preferred.<br/>
  1722. Such is the case when the filter is extremely minimal and fast.<br/>
  1723. This is because dispatch_sync is faster than dispatch_async.</p>
  1724. <p>If you choose synchronous operation, be aware of possible deadlock conditions.<br/>
  1725. Since the socket queue is executing your block via dispatch_sync,<br/>
  1726. then you cannot perform any tasks which may invoke dispatch_sync on the socket queue.<br/>
  1727. For example, you can&rsquo;t query properties on the socket.</p>
  1728. </div>
  1729. <div class="method-subsection declared-in-section">
  1730. <h4 class="method-subtitle">Declared In</h4>
  1731. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1732. </div>
  1733. </div>
  1734. <div class="section-method">
  1735. <a name="//api/name/setUserData:" title="setUserData:"></a>
  1736. <h3 class="subsubtitle method-title">setUserData:</h3>
  1737. <div class="method-subsection method-declaration"><code>- (void)setUserData:(id)<em>arbitraryUserData</em></code></div>
  1738. </div>
  1739. <div class="section-method">
  1740. <a name="//api/name/socket4FD" title="socket4FD"></a>
  1741. <h3 class="subsubtitle method-title">socket4FD</h3>
  1742. <div class="method-subsection method-declaration"><code>- (int)socket4FD</code></div>
  1743. </div>
  1744. <div class="section-method">
  1745. <a name="//api/name/socket6FD" title="socket6FD"></a>
  1746. <h3 class="subsubtitle method-title">socket6FD</h3>
  1747. <div class="method-subsection method-declaration"><code>- (int)socket6FD</code></div>
  1748. </div>
  1749. <div class="section-method">
  1750. <a name="//api/name/socketFD" title="socketFD"></a>
  1751. <h3 class="subsubtitle method-title">socketFD</h3>
  1752. <div class="method-subsection brief-description">
  1753. <p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1754. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1755. </div>
  1756. <div class="method-subsection method-declaration"><code>- (int)socketFD</code></div>
  1757. <div class="method-subsection discussion-section">
  1758. <h4 class="method-subtitle">Discussion</h4>
  1759. <p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1760. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1761. <p>Provides access to the socket&rsquo;s file descriptor(s).<br/>
  1762. If the socket isn&rsquo;t connected, or explicity bound to a particular interface,<br/>
  1763. it might actually have multiple internal socket file descriptors - one for IPv4 and one for IPv6.</p>
  1764. </div>
  1765. <div class="method-subsection declared-in-section">
  1766. <h4 class="method-subtitle">Declared In</h4>
  1767. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1768. </div>
  1769. </div>
  1770. <div class="section-method">
  1771. <a name="//api/name/synchronouslySetDelegate:" title="synchronouslySetDelegate:"></a>
  1772. <h3 class="subsubtitle method-title">synchronouslySetDelegate:</h3>
  1773. <div class="method-subsection method-declaration"><code>- (void)synchronouslySetDelegate:(id)<em>delegate</em></code></div>
  1774. </div>
  1775. <div class="section-method">
  1776. <a name="//api/name/synchronouslySetDelegate:delegateQueue:" title="synchronouslySetDelegate:delegateQueue:"></a>
  1777. <h3 class="subsubtitle method-title">synchronouslySetDelegate:delegateQueue:</h3>
  1778. <div class="method-subsection method-declaration"><code>- (void)synchronouslySetDelegate:(id)<em>delegate</em> delegateQueue:(dispatch_queue_t)<em>delegateQueue</em></code></div>
  1779. </div>
  1780. <div class="section-method">
  1781. <a name="//api/name/synchronouslySetDelegateQueue:" title="synchronouslySetDelegateQueue:"></a>
  1782. <h3 class="subsubtitle method-title">synchronouslySetDelegateQueue:</h3>
  1783. <div class="method-subsection method-declaration"><code>- (void)synchronouslySetDelegateQueue:(dispatch_queue_t)<em>delegateQueue</em></code></div>
  1784. </div>
  1785. <div class="section-method">
  1786. <a name="//api/name/userData" title="userData"></a>
  1787. <h3 class="subsubtitle method-title">userData</h3>
  1788. <div class="method-subsection brief-description">
  1789. <p>User data allows you to associate arbitrary information with the socket.<br/>
  1790. This data is not used internally in any way.</p>
  1791. </div>
  1792. <div class="method-subsection method-declaration"><code>- (id)userData</code></div>
  1793. <div class="method-subsection discussion-section">
  1794. <h4 class="method-subtitle">Discussion</h4>
  1795. <p>User data allows you to associate arbitrary information with the socket.<br/>
  1796. This data is not used internally in any way.</p>
  1797. </div>
  1798. <div class="method-subsection declared-in-section">
  1799. <h4 class="method-subtitle">Declared In</h4>
  1800. <code class="declared-in-ref">GCDAsyncUdpSocket.h</code><br />
  1801. </div>
  1802. </div>
  1803. <div class="section-method">
  1804. <a name="//api/name/writeStream" title="writeStream"></a>
  1805. <h3 class="subsubtitle method-title">writeStream</h3>
  1806. <div class="method-subsection method-declaration"><code>- (CFWriteStreamRef)writeStream</code></div>
  1807. </div>
  1808. </div>
  1809. </div>
  1810. <div class="main-navigation navigation-bottom">
  1811. <ul>
  1812. <li><a href="../index.html">Index</a></li>
  1813. <li><a href="../hierarchy.html">Hierarchy</a></li>
  1814. </ul>
  1815. </div>
  1816. <div id="footer">
  1817. <hr />
  1818. <div class="footer-copyright">
  1819. <p><span class="copyright">&copy; 2013 Dustin Voss and Robbie Hanson. All rights reserved. (Last updated: 2013-04-24)</span><br />
  1820. <span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.1 (build 858)</a>.</span></p>
  1821. </div>
  1822. </div>
  1823. </div>
  1824. </article>
  1825. <script type="text/javascript">
  1826. function jumpToChange()
  1827. {
  1828. window.location.hash = this.options[this.selectedIndex].value;
  1829. }
  1830. function toggleTOC()
  1831. {
  1832. var contents = document.getElementById('contents');
  1833. var tocContainer = document.getElementById('tocContainer');
  1834. if (this.getAttribute('class') == 'open')
  1835. {
  1836. this.setAttribute('class', '');
  1837. contents.setAttribute('class', '');
  1838. tocContainer.setAttribute('class', '');
  1839. window.name = "hideTOC";
  1840. }
  1841. else
  1842. {
  1843. this.setAttribute('class', 'open');
  1844. contents.setAttribute('class', 'isShowingTOC');
  1845. tocContainer.setAttribute('class', 'isShowingTOC');
  1846. window.name = "";
  1847. }
  1848. return false;
  1849. }
  1850. function toggleTOCEntryChildren(e)
  1851. {
  1852. e.stopPropagation();
  1853. var currentClass = this.getAttribute('class');
  1854. if (currentClass == 'children') {
  1855. this.setAttribute('class', 'children open');
  1856. }
  1857. else if (currentClass == 'children open') {
  1858. this.setAttribute('class', 'children');
  1859. }
  1860. return false;
  1861. }
  1862. function tocEntryClick(e)
  1863. {
  1864. e.stopPropagation();
  1865. return true;
  1866. }
  1867. function init()
  1868. {
  1869. var selectElement = document.getElementById('jumpTo');
  1870. selectElement.addEventListener('change', jumpToChange, false);
  1871. var tocButton = document.getElementById('table_of_contents');
  1872. tocButton.addEventListener('click', toggleTOC, false);
  1873. var taskTreeItem = document.getElementById('task_treeitem');
  1874. if (taskTreeItem.getElementsByTagName('li').length > 0)
  1875. {
  1876. taskTreeItem.setAttribute('class', 'children');
  1877. taskTreeItem.firstChild.setAttribute('class', 'disclosure');
  1878. }
  1879. var tocList = document.getElementById('toc');
  1880. var tocEntries = tocList.getElementsByTagName('li');
  1881. for (var i = 0; i < tocEntries.length; i++) {
  1882. tocEntries[i].addEventListener('click', toggleTOCEntryChildren, false);
  1883. }
  1884. var tocLinks = tocList.getElementsByTagName('a');
  1885. for (var i = 0; i < tocLinks.length; i++) {
  1886. tocLinks[i].addEventListener('click', tocEntryClick, false);
  1887. }
  1888. if (window.name == "hideTOC") {
  1889. toggleTOC.call(tocButton);
  1890. }
  1891. }
  1892. window.onload = init;
  1893. // If showing in Xcode, hide the TOC and Header
  1894. if (navigator.userAgent.match(/xcode/i)) {
  1895. document.getElementById("contents").className = "hideInXcode"
  1896. document.getElementById("tocContainer").className = "hideInXcode"
  1897. document.getElementById("top_header").className = "hideInXcode"
  1898. }
  1899. </script>
  1900. </body>
  1901. </html>