PageRenderTime 67ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/Pods/Documentation/CocoaAsyncSocket/docset/Contents/Resources/Documents/Classes/GCDAsyncSocket.html

https://gitlab.com/mba811/tokaidoapp
HTML | 3662 lines | 1919 code | 1743 blank | 0 comment | 0 complexity | 06b7c318a53495aab9a3ebf3c0b6bc20 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>GCDAsyncSocket 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">GCDAsyncSocket 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="tasks">Tasks</option>
  28. <option value="class_methods">Class Methods</option>
  29. <option value="//api/name/CRData">&nbsp;&nbsp;&nbsp;&nbsp;+ CRData</option>
  30. <option value="//api/name/CRLFData">&nbsp;&nbsp;&nbsp;&nbsp;+ CRLFData</option>
  31. <option value="//api/name/LFData">&nbsp;&nbsp;&nbsp;&nbsp;+ LFData</option>
  32. <option value="//api/name/ZeroData">&nbsp;&nbsp;&nbsp;&nbsp;+ ZeroData</option>
  33. <option value="//api/name/getHost:port:fromAddress:">&nbsp;&nbsp;&nbsp;&nbsp;+ getHost:port:fromAddress:</option>
  34. <option value="//api/name/hostFromAddress:">&nbsp;&nbsp;&nbsp;&nbsp;+ hostFromAddress:</option>
  35. <option value="//api/name/portFromAddress:">&nbsp;&nbsp;&nbsp;&nbsp;+ portFromAddress:</option>
  36. <option value="instance_methods">Instance Methods</option>
  37. <option value="//api/name/acceptOnInterface:port:error:">&nbsp;&nbsp;&nbsp;&nbsp;- acceptOnInterface:port:error:</option>
  38. <option value="//api/name/acceptOnPort:error:">&nbsp;&nbsp;&nbsp;&nbsp;- acceptOnPort:error:</option>
  39. <option value="//api/name/autoDisconnectOnClosedReadStream">&nbsp;&nbsp;&nbsp;&nbsp;- autoDisconnectOnClosedReadStream</option>
  40. <option value="//api/name/connectToAddress:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToAddress:error:</option>
  41. <option value="//api/name/connectToAddress:viaInterface:withTimeout:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToAddress:viaInterface:withTimeout:error:</option>
  42. <option value="//api/name/connectToAddress:withTimeout:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToAddress:withTimeout:error:</option>
  43. <option value="//api/name/connectToHost:onPort:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToHost:onPort:error:</option>
  44. <option value="//api/name/connectToHost:onPort:viaInterface:withTimeout:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToHost:onPort:viaInterface:withTimeout:error:</option>
  45. <option value="//api/name/connectToHost:onPort:withTimeout:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToHost:onPort:withTimeout: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/disconnect">&nbsp;&nbsp;&nbsp;&nbsp;- disconnect</option>
  52. <option value="//api/name/disconnectAfterReading">&nbsp;&nbsp;&nbsp;&nbsp;- disconnectAfterReading</option>
  53. <option value="//api/name/disconnectAfterReadingAndWriting">&nbsp;&nbsp;&nbsp;&nbsp;- disconnectAfterReadingAndWriting</option>
  54. <option value="//api/name/disconnectAfterWriting">&nbsp;&nbsp;&nbsp;&nbsp;- disconnectAfterWriting</option>
  55. <option value="//api/name/enableBackgroundingOnSocket">&nbsp;&nbsp;&nbsp;&nbsp;- enableBackgroundingOnSocket</option>
  56. <option value="//api/name/getDelegate:delegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- getDelegate:delegateQueue:</option>
  57. <option value="//api/name/init">&nbsp;&nbsp;&nbsp;&nbsp;- init</option>
  58. <option value="//api/name/initWithDelegate:delegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- initWithDelegate:delegateQueue:</option>
  59. <option value="//api/name/initWithDelegate:delegateQueue:socketQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- initWithDelegate:delegateQueue:socketQueue:</option>
  60. <option value="//api/name/initWithSocketQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- initWithSocketQueue:</option>
  61. <option value="//api/name/isConnected">&nbsp;&nbsp;&nbsp;&nbsp;- isConnected</option>
  62. <option value="//api/name/isDisconnected">&nbsp;&nbsp;&nbsp;&nbsp;- isDisconnected</option>
  63. <option value="//api/name/isIPv4">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv4</option>
  64. <option value="//api/name/isIPv4Enabled">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv4Enabled</option>
  65. <option value="//api/name/isIPv4PreferredOverIPv6">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv4PreferredOverIPv6</option>
  66. <option value="//api/name/isIPv6">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv6</option>
  67. <option value="//api/name/isIPv6Enabled">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv6Enabled</option>
  68. <option value="//api/name/isSecure">&nbsp;&nbsp;&nbsp;&nbsp;- isSecure</option>
  69. <option value="//api/name/localAddress">&nbsp;&nbsp;&nbsp;&nbsp;- localAddress</option>
  70. <option value="//api/name/localHost">&nbsp;&nbsp;&nbsp;&nbsp;- localHost</option>
  71. <option value="//api/name/localPort">&nbsp;&nbsp;&nbsp;&nbsp;- localPort</option>
  72. <option value="//api/name/performBlock:">&nbsp;&nbsp;&nbsp;&nbsp;- performBlock:</option>
  73. <option value="//api/name/progressOfReadReturningTag:bytesDone:total:">&nbsp;&nbsp;&nbsp;&nbsp;- progressOfReadReturningTag:bytesDone:total:</option>
  74. <option value="//api/name/progressOfWriteReturningTag:bytesDone:total:">&nbsp;&nbsp;&nbsp;&nbsp;- progressOfWriteReturningTag:bytesDone:total:</option>
  75. <option value="//api/name/readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:</option>
  76. <option value="//api/name/readDataToData:withTimeout:buffer:bufferOffset:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToData:withTimeout:buffer:bufferOffset:tag:</option>
  77. <option value="//api/name/readDataToData:withTimeout:maxLength:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToData:withTimeout:maxLength:tag:</option>
  78. <option value="//api/name/readDataToData:withTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToData:withTimeout:tag:</option>
  79. <option value="//api/name/readDataToLength:withTimeout:buffer:bufferOffset:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToLength:withTimeout:buffer:bufferOffset:tag:</option>
  80. <option value="//api/name/readDataToLength:withTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToLength:withTimeout:tag:</option>
  81. <option value="//api/name/readDataWithTimeout:buffer:bufferOffset:maxLength:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataWithTimeout:buffer:bufferOffset:maxLength:tag:</option>
  82. <option value="//api/name/readDataWithTimeout:buffer:bufferOffset:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataWithTimeout:buffer:bufferOffset:tag:</option>
  83. <option value="//api/name/readDataWithTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataWithTimeout:tag:</option>
  84. <option value="//api/name/readStream">&nbsp;&nbsp;&nbsp;&nbsp;- readStream</option>
  85. <option value="//api/name/setAutoDisconnectOnClosedReadStream:">&nbsp;&nbsp;&nbsp;&nbsp;- setAutoDisconnectOnClosedReadStream:</option>
  86. <option value="//api/name/setDelegate:">&nbsp;&nbsp;&nbsp;&nbsp;- setDelegate:</option>
  87. <option value="//api/name/setDelegate:delegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- setDelegate:delegateQueue:</option>
  88. <option value="//api/name/setDelegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- setDelegateQueue:</option>
  89. <option value="//api/name/setIPv4Enabled:">&nbsp;&nbsp;&nbsp;&nbsp;- setIPv4Enabled:</option>
  90. <option value="//api/name/setIPv6Enabled:">&nbsp;&nbsp;&nbsp;&nbsp;- setIPv6Enabled:</option>
  91. <option value="//api/name/setPreferIPv4OverIPv6:">&nbsp;&nbsp;&nbsp;&nbsp;- setPreferIPv4OverIPv6:</option>
  92. <option value="//api/name/setUserData:">&nbsp;&nbsp;&nbsp;&nbsp;- setUserData:</option>
  93. <option value="//api/name/socket4FD">&nbsp;&nbsp;&nbsp;&nbsp;- socket4FD</option>
  94. <option value="//api/name/socket6FD">&nbsp;&nbsp;&nbsp;&nbsp;- socket6FD</option>
  95. <option value="//api/name/socketFD">&nbsp;&nbsp;&nbsp;&nbsp;- socketFD</option>
  96. <option value="//api/name/sslContext">&nbsp;&nbsp;&nbsp;&nbsp;- sslContext</option>
  97. <option value="//api/name/startTLS:">&nbsp;&nbsp;&nbsp;&nbsp;- startTLS:</option>
  98. <option value="//api/name/synchronouslySetDelegate:">&nbsp;&nbsp;&nbsp;&nbsp;- synchronouslySetDelegate:</option>
  99. <option value="//api/name/synchronouslySetDelegate:delegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- synchronouslySetDelegate:delegateQueue:</option>
  100. <option value="//api/name/synchronouslySetDelegateQueue:">&nbsp;&nbsp;&nbsp;&nbsp;- synchronouslySetDelegateQueue:</option>
  101. <option value="//api/name/userData">&nbsp;&nbsp;&nbsp;&nbsp;- userData</option>
  102. <option value="//api/name/writeData:withTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- writeData:withTimeout:tag:</option>
  103. <option value="//api/name/writeStream">&nbsp;&nbsp;&nbsp;&nbsp;- writeStream</option>
  104. </select>
  105. </li>
  106. </ul>
  107. </header>
  108. <nav id="tocContainer" class="isShowingTOC">
  109. <ul id="toc" role="tree">
  110. <li role="treeitem" id="task_treeitem"><span class="nodisclosure"></span><span class="sectionName"><a href="#tasks">Tasks</a></span><ul>
  111. </ul></li>
  112. <li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#class_methods">Class Methods</a></span><ul>
  113. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/CRData">CRData</a></span></li>
  114. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/CRLFData">CRLFData</a></span></li>
  115. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/LFData">LFData</a></span></li>
  116. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/ZeroData">ZeroData</a></span></li>
  117. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/getHost:port:fromAddress:">getHost:port:fromAddress:</a></span></li>
  118. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/hostFromAddress:">hostFromAddress:</a></span></li>
  119. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/portFromAddress:">portFromAddress:</a></span></li>
  120. </ul></li>
  121. <li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#instance_methods">Instance Methods</a></span><ul>
  122. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/acceptOnInterface:port:error:">acceptOnInterface:port:error:</a></span></li>
  123. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a></span></li>
  124. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/autoDisconnectOnClosedReadStream">autoDisconnectOnClosedReadStream</a></span></li>
  125. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a></span></li>
  126. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToAddress:viaInterface:withTimeout:error:">connectToAddress:viaInterface:withTimeout:error:</a></span></li>
  127. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToAddress:withTimeout:error:">connectToAddress:withTimeout:error:</a></span></li>
  128. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a></span></li>
  129. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToHost:onPort:viaInterface:withTimeout:error:">connectToHost:onPort:viaInterface:withTimeout:error:</a></span></li>
  130. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToHost:onPort:withTimeout:error:">connectToHost:onPort:withTimeout:error:</a></span></li>
  131. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectedAddress">connectedAddress</a></span></li>
  132. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectedHost">connectedHost</a></span></li>
  133. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectedPort">connectedPort</a></span></li>
  134. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/delegate">delegate</a></span></li>
  135. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/delegateQueue">delegateQueue</a></span></li>
  136. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/disconnect">disconnect</a></span></li>
  137. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/disconnectAfterReading">disconnectAfterReading</a></span></li>
  138. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/disconnectAfterReadingAndWriting">disconnectAfterReadingAndWriting</a></span></li>
  139. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/disconnectAfterWriting">disconnectAfterWriting</a></span></li>
  140. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/enableBackgroundingOnSocket">enableBackgroundingOnSocket</a></span></li>
  141. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/getDelegate:delegateQueue:">getDelegate:delegateQueue:</a></span></li>
  142. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/init">init</a></span></li>
  143. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/initWithDelegate:delegateQueue:">initWithDelegate:delegateQueue:</a></span></li>
  144. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/initWithDelegate:delegateQueue:socketQueue:">initWithDelegate:delegateQueue:socketQueue:</a></span></li>
  145. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/initWithSocketQueue:">initWithSocketQueue:</a></span></li>
  146. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isConnected">isConnected</a></span></li>
  147. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isDisconnected">isDisconnected</a></span></li>
  148. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv4">isIPv4</a></span></li>
  149. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv4Enabled">isIPv4Enabled</a></span></li>
  150. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv4PreferredOverIPv6">isIPv4PreferredOverIPv6</a></span></li>
  151. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv6">isIPv6</a></span></li>
  152. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv6Enabled">isIPv6Enabled</a></span></li>
  153. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isSecure">isSecure</a></span></li>
  154. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localAddress">localAddress</a></span></li>
  155. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localHost">localHost</a></span></li>
  156. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localPort">localPort</a></span></li>
  157. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/performBlock:">performBlock:</a></span></li>
  158. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/progressOfReadReturningTag:bytesDone:total:">progressOfReadReturningTag:bytesDone:total:</a></span></li>
  159. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/progressOfWriteReturningTag:bytesDone:total:">progressOfWriteReturningTag:bytesDone:total:</a></span></li>
  160. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:">readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:</a></span></li>
  161. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataToData:withTimeout:buffer:bufferOffset:tag:">readDataToData:withTimeout:buffer:bufferOffset:tag:</a></span></li>
  162. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataToData:withTimeout:maxLength:tag:">readDataToData:withTimeout:maxLength:tag:</a></span></li>
  163. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataToData:withTimeout:tag:">readDataToData:withTimeout:tag:</a></span></li>
  164. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataToLength:withTimeout:buffer:bufferOffset:tag:">readDataToLength:withTimeout:buffer:bufferOffset:tag:</a></span></li>
  165. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataToLength:withTimeout:tag:">readDataToLength:withTimeout:tag:</a></span></li>
  166. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataWithTimeout:buffer:bufferOffset:maxLength:tag:">readDataWithTimeout:buffer:bufferOffset:maxLength:tag:</a></span></li>
  167. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataWithTimeout:buffer:bufferOffset:tag:">readDataWithTimeout:buffer:bufferOffset:tag:</a></span></li>
  168. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataWithTimeout:tag:">readDataWithTimeout:tag:</a></span></li>
  169. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readStream">readStream</a></span></li>
  170. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setAutoDisconnectOnClosedReadStream:">setAutoDisconnectOnClosedReadStream:</a></span></li>
  171. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setDelegate:">setDelegate:</a></span></li>
  172. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setDelegate:delegateQueue:">setDelegate:delegateQueue:</a></span></li>
  173. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setDelegateQueue:">setDelegateQueue:</a></span></li>
  174. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setIPv4Enabled:">setIPv4Enabled:</a></span></li>
  175. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setIPv6Enabled:">setIPv6Enabled:</a></span></li>
  176. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setPreferIPv4OverIPv6:">setPreferIPv4OverIPv6:</a></span></li>
  177. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setUserData:">setUserData:</a></span></li>
  178. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/socket4FD">socket4FD</a></span></li>
  179. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/socket6FD">socket6FD</a></span></li>
  180. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/socketFD">socketFD</a></span></li>
  181. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/sslContext">sslContext</a></span></li>
  182. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/startTLS:">startTLS:</a></span></li>
  183. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/synchronouslySetDelegate:">synchronouslySetDelegate:</a></span></li>
  184. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/synchronouslySetDelegate:delegateQueue:">synchronouslySetDelegate:delegateQueue:</a></span></li>
  185. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/synchronouslySetDelegateQueue:">synchronouslySetDelegateQueue:</a></span></li>
  186. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/userData">userData</a></span></li>
  187. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/writeData:withTimeout:tag:">writeData:withTimeout:tag:</a></span></li>
  188. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/writeStream">writeStream</a></span></li>
  189. </ul></li>
  190. </ul>
  191. </nav>
  192. <article>
  193. <div id="contents" class="isShowingTOC" role="main">
  194. <a title="GCDAsyncSocket Class Reference" name="top"></a>
  195. <div class="main-navigation navigation-top">
  196. <ul>
  197. <li><a href="../index.html">Index</a></li>
  198. <li><a href="../hierarchy.html">Hierarchy</a></li>
  199. </ul>
  200. </div>
  201. <div id="header">
  202. <div class="section-header">
  203. <h1 class="title title-header">GCDAsyncSocket Class Reference</h1>
  204. </div>
  205. </div>
  206. <div id="container">
  207. <div class="section section-specification"><table cellspacing="0"><tbody>
  208. <tr>
  209. <td class="specification-title">Inherits from</td>
  210. <td class="specification-value">NSObject</td>
  211. </tr><tr>
  212. <td class="specification-title">Declared in</td>
  213. <td class="specification-value">GCDAsyncSocket.h</td>
  214. </tr>
  215. </tbody></table></div>
  216. <div class="section section-tasks">
  217. <a title="Tasks" name="tasks"></a>
  218. <h2 class="subtitle subtitle-tasks">Tasks</h2>
  219. <ul class="task-list">
  220. <li>
  221. <span class="tooltip">
  222. <code><a href="#//api/name/init">&ndash;&nbsp;init</a></code>
  223. <span class="tooltip"><p>GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> uses the standard <a href="#//api/name/delegate">delegate</a> paradigm,<br/>
  224. but executes all <a href="#//api/name/delegate">delegate</a> callbacks on a given <a href="#//api/name/delegate">delegate</a> dispatch queue.<br/>
  225. This allows for maximum concurrency, while at the same time providing easy thread safety.</p></span>
  226. </span>
  227. </li><li>
  228. <span class="tooltip">
  229. <code><a href="#//api/name/initWithSocketQueue:">&ndash;&nbsp;initWithSocketQueue:</a></code>
  230. </span>
  231. </li><li>
  232. <span class="tooltip">
  233. <code><a href="#//api/name/initWithDelegate:delegateQueue:">&ndash;&nbsp;initWithDelegate:delegateQueue:</a></code>
  234. </span>
  235. </li><li>
  236. <span class="tooltip">
  237. <code><a href="#//api/name/initWithDelegate:delegateQueue:socketQueue:">&ndash;&nbsp;initWithDelegate:delegateQueue:socketQueue:</a></code>
  238. </span>
  239. </li><li>
  240. <span class="tooltip">
  241. <code><a href="#//api/name/delegate">&ndash;&nbsp;delegate</a></code>
  242. </span>
  243. </li><li>
  244. <span class="tooltip">
  245. <code><a href="#//api/name/setDelegate:">&ndash;&nbsp;setDelegate:</a></code>
  246. </span>
  247. </li><li>
  248. <span class="tooltip">
  249. <code><a href="#//api/name/synchronouslySetDelegate:">&ndash;&nbsp;synchronouslySetDelegate:</a></code>
  250. </span>
  251. </li><li>
  252. <span class="tooltip">
  253. <code><a href="#//api/name/delegateQueue">&ndash;&nbsp;delegateQueue</a></code>
  254. </span>
  255. </li><li>
  256. <span class="tooltip">
  257. <code><a href="#//api/name/setDelegateQueue:">&ndash;&nbsp;setDelegateQueue:</a></code>
  258. </span>
  259. </li><li>
  260. <span class="tooltip">
  261. <code><a href="#//api/name/synchronouslySetDelegateQueue:">&ndash;&nbsp;synchronouslySetDelegateQueue:</a></code>
  262. </span>
  263. </li><li>
  264. <span class="tooltip">
  265. <code><a href="#//api/name/getDelegate:delegateQueue:">&ndash;&nbsp;getDelegate:delegateQueue:</a></code>
  266. </span>
  267. </li><li>
  268. <span class="tooltip">
  269. <code><a href="#//api/name/setDelegate:delegateQueue:">&ndash;&nbsp;setDelegate:delegateQueue:</a></code>
  270. </span>
  271. </li><li>
  272. <span class="tooltip">
  273. <code><a href="#//api/name/synchronouslySetDelegate:delegateQueue:">&ndash;&nbsp;synchronouslySetDelegate:delegateQueue:</a></code>
  274. </span>
  275. </li><li>
  276. <span class="tooltip">
  277. <code><a href="#//api/name/autoDisconnectOnClosedReadStream">&ndash;&nbsp;autoDisconnectOnClosedReadStream</a></code>
  278. <span class="tooltip"><p>Traditionally sockets are not closed until the conversation is over.<br/>
  279. However, it is technically possible for the remote enpoint to close its write stream.<br/>
  280. Our socket would then be notified that there is no more data to be read,<br/>
  281. but our socket would still be writeable and the remote endpoint could continue to receive our data.</p></span>
  282. </span>
  283. </li><li>
  284. <span class="tooltip">
  285. <code><a href="#//api/name/setAutoDisconnectOnClosedReadStream:">&ndash;&nbsp;setAutoDisconnectOnClosedReadStream:</a></code>
  286. </span>
  287. </li><li>
  288. <span class="tooltip">
  289. <code><a href="#//api/name/isIPv4Enabled">&ndash;&nbsp;isIPv4Enabled</a></code>
  290. <span class="tooltip"><p>By default, both IPv4 and IPv6 are enabled.</p></span>
  291. </span>
  292. </li><li>
  293. <span class="tooltip">
  294. <code><a href="#//api/name/setIPv4Enabled:">&ndash;&nbsp;setIPv4Enabled:</a></code>
  295. </span>
  296. </li><li>
  297. <span class="tooltip">
  298. <code><a href="#//api/name/isIPv6Enabled">&ndash;&nbsp;isIPv6Enabled</a></code>
  299. </span>
  300. </li><li>
  301. <span class="tooltip">
  302. <code><a href="#//api/name/setIPv6Enabled:">&ndash;&nbsp;setIPv6Enabled:</a></code>
  303. </span>
  304. </li><li>
  305. <span class="tooltip">
  306. <code><a href="#//api/name/isIPv4PreferredOverIPv6">&ndash;&nbsp;isIPv4PreferredOverIPv6</a></code>
  307. </span>
  308. </li><li>
  309. <span class="tooltip">
  310. <code><a href="#//api/name/setPreferIPv4OverIPv6:">&ndash;&nbsp;setPreferIPv4OverIPv6:</a></code>
  311. </span>
  312. </li><li>
  313. <span class="tooltip">
  314. <code><a href="#//api/name/userData">&ndash;&nbsp;userData</a></code>
  315. <span class="tooltip"><p>User data allows you to associate arbitrary information with the socket.<br/>
  316. This data is not used internally by socket in any way.</p></span>
  317. </span>
  318. </li><li>
  319. <span class="tooltip">
  320. <code><a href="#//api/name/setUserData:">&ndash;&nbsp;setUserData:</a></code>
  321. </span>
  322. </li><li>
  323. <span class="tooltip">
  324. <code><a href="#//api/name/acceptOnPort:error:">&ndash;&nbsp;acceptOnPort:error:</a></code>
  325. <span class="tooltip"><p>Tells the socket to begin listening and accepting connections on the given port.<br/>
  326. When a connection is accepted, a new instance of GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> will be spawned to handle it,<br/>
  327. and the socket:didAcceptNewSocket: <a href="#//api/name/delegate">delegate</a> method will be invoked.</p></span>
  328. </span>
  329. </li><li>
  330. <span class="tooltip">
  331. <code><a href="#//api/name/acceptOnInterface:port:error:">&ndash;&nbsp;acceptOnInterface:port:error:</a></code>
  332. <span class="tooltip"><p>This method is the same as <a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a> with the<br/>
  333. additional option of specifying which interface to listen on.</p></span>
  334. </span>
  335. </li><li>
  336. <span class="tooltip">
  337. <code><a href="#//api/name/connectToHost:onPort:error:">&ndash;&nbsp;connectToHost:onPort:error:</a></code>
  338. <span class="tooltip"><p>Connects to the given host and port.</p></span>
  339. </span>
  340. </li><li>
  341. <span class="tooltip">
  342. <code><a href="#//api/name/connectToHost:onPort:withTimeout:error:">&ndash;&nbsp;connectToHost:onPort:withTimeout:error:</a></code>
  343. <span class="tooltip"><p>Connects to the given host and port with an optional timeout.</p></span>
  344. </span>
  345. </li><li>
  346. <span class="tooltip">
  347. <code><a href="#//api/name/connectToHost:onPort:viaInterface:withTimeout:error:">&ndash;&nbsp;connectToHost:onPort:viaInterface:withTimeout:error:</a></code>
  348. <span class="tooltip"><p>Connects to the given host &amp; port, via the optional interface, with an optional timeout.</p></span>
  349. </span>
  350. </li><li>
  351. <span class="tooltip">
  352. <code><a href="#//api/name/connectToAddress:error:">&ndash;&nbsp;connectToAddress:error:</a></code>
  353. <span class="tooltip"><p>Connects to the given address, specified as a sockaddr structure wrapped in a NSData object.<br/>
  354. For example, a NSData object returned from NSNetService&rsquo;s addresses method.</p></span>
  355. </span>
  356. </li><li>
  357. <span class="tooltip">
  358. <code><a href="#//api/name/connectToAddress:withTimeout:error:">&ndash;&nbsp;connectToAddress:withTimeout:error:</a></code>
  359. <span class="tooltip"><p>This method is the same as <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> with an additional timeout option.<br/>
  360. To not time out use a negative time interval, or simply use the <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> method.</p></span>
  361. </span>
  362. </li><li>
  363. <span class="tooltip">
  364. <code><a href="#//api/name/connectToAddress:viaInterface:withTimeout:error:">&ndash;&nbsp;connectToAddress:viaInterface:withTimeout:error:</a></code>
  365. <span class="tooltip"><p>Connects to the given address, using the specified interface and timeout.</p></span>
  366. </span>
  367. </li><li>
  368. <span class="tooltip">
  369. <code><a href="#//api/name/disconnect">&ndash;&nbsp;disconnect</a></code>
  370. <span class="tooltip"><p>Disconnects immediately (synchronously). Any pending reads or writes are dropped.</p></span>
  371. </span>
  372. </li><li>
  373. <span class="tooltip">
  374. <code><a href="#//api/name/disconnectAfterReading">&ndash;&nbsp;disconnectAfterReading</a></code>
  375. <span class="tooltip"><p>Disconnects after all pending reads have completed.<br/>
  376. After calling this, the read and write methods will do nothing.<br/>
  377. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending writes.</p></span>
  378. </span>
  379. </li><li>
  380. <span class="tooltip">
  381. <code><a href="#//api/name/disconnectAfterWriting">&ndash;&nbsp;disconnectAfterWriting</a></code>
  382. <span class="tooltip"><p>Disconnects after all pending writes have completed.<br/>
  383. After calling this, the read and write methods will do nothing.<br/>
  384. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending reads.</p></span>
  385. </span>
  386. </li><li>
  387. <span class="tooltip">
  388. <code><a href="#//api/name/disconnectAfterReadingAndWriting">&ndash;&nbsp;disconnectAfterReadingAndWriting</a></code>
  389. <span class="tooltip"><p>Disconnects after all pending reads and writes have completed.<br/>
  390. After calling this, the read and write methods will do nothing.</p></span>
  391. </span>
  392. </li><li>
  393. <span class="tooltip">
  394. <code><a href="#//api/name/isDisconnected">&ndash;&nbsp;isDisconnected</a></code>
  395. <span class="tooltip"><p>Returns whether the socket is disconnected or connected.</p></span>
  396. </span>
  397. </li><li>
  398. <span class="tooltip">
  399. <code><a href="#//api/name/isConnected">&ndash;&nbsp;isConnected</a></code>
  400. </span>
  401. </li><li>
  402. <span class="tooltip">
  403. <code><a href="#//api/name/connectedHost">&ndash;&nbsp;connectedHost</a></code>
  404. <span class="tooltip"><p>Returns the local or remote host and port to which this socket is connected, or nil and 0 if not connected.<br/>
  405. The host will be an IP address.</p></span>
  406. </span>
  407. </li><li>
  408. <span class="tooltip">
  409. <code><a href="#//api/name/connectedPort">&ndash;&nbsp;connectedPort</a></code>
  410. </span>
  411. </li><li>
  412. <span class="tooltip">
  413. <code><a href="#//api/name/localHost">&ndash;&nbsp;localHost</a></code>
  414. </span>
  415. </li><li>
  416. <span class="tooltip">
  417. <code><a href="#//api/name/localPort">&ndash;&nbsp;localPort</a></code>
  418. </span>
  419. </li><li>
  420. <span class="tooltip">
  421. <code><a href="#//api/name/connectedAddress">&ndash;&nbsp;connectedAddress</a></code>
  422. <span class="tooltip"><p>Returns the local or remote address to which this socket is connected,<br/>
  423. specified as a sockaddr structure wrapped in a NSData object.</p></span>
  424. </span>
  425. </li><li>
  426. <span class="tooltip">
  427. <code><a href="#//api/name/localAddress">&ndash;&nbsp;localAddress</a></code>
  428. </span>
  429. </li><li>
  430. <span class="tooltip">
  431. <code><a href="#//api/name/isIPv4">&ndash;&nbsp;isIPv4</a></code>
  432. <span class="tooltip"><p>Returns whether the socket is IPv4 or IPv6.<br/>
  433. An accepting socket may be both.</p></span>
  434. </span>
  435. </li><li>
  436. <span class="tooltip">
  437. <code><a href="#//api/name/isIPv6">&ndash;&nbsp;isIPv6</a></code>
  438. </span>
  439. </li><li>
  440. <span class="tooltip">
  441. <code><a href="#//api/name/isSecure">&ndash;&nbsp;isSecure</a></code>
  442. <span class="tooltip"><p>Returns whether or not the socket has been secured via SSL/TLS.</p></span>
  443. </span>
  444. </li><li>
  445. <span class="tooltip">
  446. <code><a href="#//api/name/readDataWithTimeout:tag:">&ndash;&nbsp;readDataWithTimeout:tag:</a></code>
  447. <span class="tooltip"><p>Reads the first available bytes that become available on the socket.</p></span>
  448. </span>
  449. </li><li>
  450. <span class="tooltip">
  451. <code><a href="#//api/name/readDataWithTimeout:buffer:bufferOffset:tag:">&ndash;&nbsp;readDataWithTimeout:buffer:bufferOffset:tag:</a></code>
  452. <span class="tooltip"><p>Reads the first available bytes that become available on the socket.<br/>
  453. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  454. The given buffer will automatically be increased in size if needed.</p></span>
  455. </span>
  456. </li><li>
  457. <span class="tooltip">
  458. <code><a href="#//api/name/readDataWithTimeout:buffer:bufferOffset:maxLength:tag:">&ndash;&nbsp;readDataWithTimeout:buffer:bufferOffset:maxLength:tag:</a></code>
  459. <span class="tooltip"><p>Reads the first available bytes that become available on the socket.<br/>
  460. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  461. The given buffer will automatically be increased in size if needed.<br/>
  462. A maximum of length bytes will be read.</p></span>
  463. </span>
  464. </li><li>
  465. <span class="tooltip">
  466. <code><a href="#//api/name/readDataToLength:withTimeout:tag:">&ndash;&nbsp;readDataToLength:withTimeout:tag:</a></code>
  467. <span class="tooltip"><p>Reads the given number of bytes.</p></span>
  468. </span>
  469. </li><li>
  470. <span class="tooltip">
  471. <code><a href="#//api/name/readDataToLength:withTimeout:buffer:bufferOffset:tag:">&ndash;&nbsp;readDataToLength:withTimeout:buffer:bufferOffset:tag:</a></code>
  472. <span class="tooltip"><p>Reads the given number of bytes.<br/>
  473. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  474. The given buffer will automatically be increased in size if needed.</p></span>
  475. </span>
  476. </li><li>
  477. <span class="tooltip">
  478. <code><a href="#//api/name/readDataToData:withTimeout:tag:">&ndash;&nbsp;readDataToData:withTimeout:tag:</a></code>
  479. <span class="tooltip"><p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p></span>
  480. </span>
  481. </li><li>
  482. <span class="tooltip">
  483. <code><a href="#//api/name/readDataToData:withTimeout:buffer:bufferOffset:tag:">&ndash;&nbsp;readDataToData:withTimeout:buffer:bufferOffset:tag:</a></code>
  484. <span class="tooltip"><p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  485. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  486. The given buffer will automatically be increased in size if needed.</p></span>
  487. </span>
  488. </li><li>
  489. <span class="tooltip">
  490. <code><a href="#//api/name/readDataToData:withTimeout:maxLength:tag:">&ndash;&nbsp;readDataToData:withTimeout:maxLength:tag:</a></code>
  491. <span class="tooltip"><p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p></span>
  492. </span>
  493. </li><li>
  494. <span class="tooltip">
  495. <code><a href="#//api/name/readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:">&ndash;&nbsp;readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:</a></code>
  496. <span class="tooltip"><p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  497. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  498. The given buffer will automatically be increased in size if needed.</p></span>
  499. </span>
  500. </li><li>
  501. <span class="tooltip">
  502. <code><a href="#//api/name/progressOfReadReturningTag:bytesDone:total:">&ndash;&nbsp;progressOfReadReturningTag:bytesDone:total:</a></code>
  503. <span class="tooltip"><p>Returns progress of the current read, from 0.0 to 1.0, or NaN if no current read (use isnan() to check).<br/>
  504. The parameters &ldquo;tag&rdquo;, &ldquo;done&rdquo; and &ldquo;total&rdquo; will be filled in if they aren&rsquo;t NULL.</p></span>
  505. </span>
  506. </li><li>
  507. <span class="tooltip">
  508. <code><a href="#//api/name/writeData:withTimeout:tag:">&ndash;&nbsp;writeData:withTimeout:tag:</a></code>
  509. <span class="tooltip"><p>Writes data to the socket, and calls the <a href="#//api/name/delegate">delegate</a> when finished.</p></span>
  510. </span>
  511. </li><li>
  512. <span class="tooltip">
  513. <code><a href="#//api/name/progressOfWriteReturningTag:bytesDone:total:">&ndash;&nbsp;progressOfWriteReturningTag:bytesDone:total:</a></code>
  514. <span class="tooltip"><p>Returns progress of the current write, from 0.0 to 1.0, or NaN if no current write (use isnan() to check).<br/>
  515. The parameters &ldquo;tag&rdquo;, &ldquo;done&rdquo; and &ldquo;total&rdquo; will be filled in if they aren&rsquo;t NULL.</p></span>
  516. </span>
  517. </li><li>
  518. <span class="tooltip">
  519. <code><a href="#//api/name/startTLS:">&ndash;&nbsp;startTLS:</a></code>
  520. <span class="tooltip"><p>Secures the connection using SSL/TLS.</p></span>
  521. </span>
  522. </li><li>
  523. <span class="tooltip">
  524. <code><a href="#//api/name/performBlock:">&ndash;&nbsp;performBlock:</a></code>
  525. <span class="tooltip"><p>It&rsquo;s not thread-safe to access certain variables from outside the socket&rsquo;s internal queue.</p></span>
  526. </span>
  527. </li><li>
  528. <span class="tooltip">
  529. <code><a href="#//api/name/socketFD">&ndash;&nbsp;socketFD</a></code>
  530. <span class="tooltip"><p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  531. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p></span>
  532. </span>
  533. </li><li>
  534. <span class="tooltip">
  535. <code><a href="#//api/name/socket4FD">&ndash;&nbsp;socket4FD</a></code>
  536. </span>
  537. </li><li>
  538. <span class="tooltip">
  539. <code><a href="#//api/name/socket6FD">&ndash;&nbsp;socket6FD</a></code>
  540. </span>
  541. </li><li>
  542. <span class="tooltip">
  543. <code><a href="#//api/name/readStream">&ndash;&nbsp;readStream</a></code>
  544. <span class="tooltip"><p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  545. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p></span>
  546. </span>
  547. </li><li>
  548. <span class="tooltip">
  549. <code><a href="#//api/name/writeStream">&ndash;&nbsp;writeStream</a></code>
  550. </span>
  551. </li><li>
  552. <span class="tooltip">
  553. <code><a href="#//api/name/enableBackgroundingOnSocket">&ndash;&nbsp;enableBackgroundingOnSocket</a></code>
  554. <span class="tooltip"><p>This method is only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  555. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p></span>
  556. </span>
  557. </li><li>
  558. <span class="tooltip">
  559. <code><a href="#//api/name/sslContext">&ndash;&nbsp;sslContext</a></code>
  560. <span class="tooltip"><p>This method is only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  561. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p></span>
  562. </span>
  563. </li><li>
  564. <span class="tooltip">
  565. <code><a href="#//api/name/hostFromAddress:">+&nbsp;hostFromAddress:</a></code>
  566. <span class="tooltip"><p>Extracting host and port information from raw address data.</p></span>
  567. </span>
  568. </li><li>
  569. <span class="tooltip">
  570. <code><a href="#//api/name/portFromAddress:">+&nbsp;portFromAddress:</a></code>
  571. </span>
  572. </li><li>
  573. <span class="tooltip">
  574. <code><a href="#//api/name/getHost:port:fromAddress:">+&nbsp;getHost:port:fromAddress:</a></code>
  575. </span>
  576. </li><li>
  577. <span class="tooltip">
  578. <code><a href="#//api/name/CRLFData">+&nbsp;CRLFData</a></code>
  579. <span class="tooltip"><p>A few common line separators, for use with the readDataToData:&hellip; methods.</p></span>
  580. </span>
  581. </li><li>
  582. <span class="tooltip">
  583. <code><a href="#//api/name/CRData">+&nbsp;CRData</a></code>
  584. </span>
  585. </li><li>
  586. <span class="tooltip">
  587. <code><a href="#//api/name/LFData">+&nbsp;LFData</a></code>
  588. </span>
  589. </li><li>
  590. <span class="tooltip">
  591. <code><a href="#//api/name/ZeroData">+&nbsp;ZeroData</a></code>
  592. </span>
  593. </li>
  594. </ul>
  595. </div>
  596. <div class="section section-methods">
  597. <a title="Class Methods" name="class_methods"></a>
  598. <h2 class="subtitle subtitle-methods">Class Methods</h2>
  599. <div class="section-method">
  600. <a name="//api/name/CRData" title="CRData"></a>
  601. <h3 class="subsubtitle method-title">CRData</h3>
  602. <div class="method-subsection method-declaration"><code>+ (NSData *)CRData</code></div>
  603. </div>
  604. <div class="section-method">
  605. <a name="//api/name/CRLFData" title="CRLFData"></a>
  606. <h3 class="subsubtitle method-title">CRLFData</h3>
  607. <div class="method-subsection brief-description">
  608. <p>A few common line separators, for use with the readDataToData:&hellip; methods.</p>
  609. </div>
  610. <div class="method-subsection method-declaration"><code>+ (NSData *)CRLFData</code></div>
  611. <div class="method-subsection discussion-section">
  612. <h4 class="method-subtitle">Discussion</h4>
  613. <p>A few common line separators, for use with the readDataToData:&hellip; methods.</p>
  614. </div>
  615. <div class="method-subsection declared-in-section">
  616. <h4 class="method-subtitle">Declared In</h4>
  617. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  618. </div>
  619. </div>
  620. <div class="section-method">
  621. <a name="//api/name/LFData" title="LFData"></a>
  622. <h3 class="subsubtitle method-title">LFData</h3>
  623. <div class="method-subsection method-declaration"><code>+ (NSData *)LFData</code></div>
  624. </div>
  625. <div class="section-method">
  626. <a name="//api/name/ZeroData" title="ZeroData"></a>
  627. <h3 class="subsubtitle method-title">ZeroData</h3>
  628. <div class="method-subsection method-declaration"><code>+ (NSData *)ZeroData</code></div>
  629. </div>
  630. <div class="section-method">
  631. <a name="//api/name/getHost:port:fromAddress:" title="getHost:port:fromAddress:"></a>
  632. <h3 class="subsubtitle method-title">getHost:port:fromAddress:</h3>
  633. <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>
  634. </div>
  635. <div class="section-method">
  636. <a name="//api/name/hostFromAddress:" title="hostFromAddress:"></a>
  637. <h3 class="subsubtitle method-title">hostFromAddress:</h3>
  638. <div class="method-subsection brief-description">
  639. <p>Extracting host and port information from raw address data.</p>
  640. </div>
  641. <div class="method-subsection method-declaration"><code>+ (NSString *)hostFromAddress:(NSData *)<em>address</em></code></div>
  642. <div class="method-subsection discussion-section">
  643. <h4 class="method-subtitle">Discussion</h4>
  644. <p>Extracting host and port information from raw address data.</p>
  645. </div>
  646. <div class="method-subsection declared-in-section">
  647. <h4 class="method-subtitle">Declared In</h4>
  648. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  649. </div>
  650. </div>
  651. <div class="section-method">
  652. <a name="//api/name/portFromAddress:" title="portFromAddress:"></a>
  653. <h3 class="subsubtitle method-title">portFromAddress:</h3>
  654. <div class="method-subsection method-declaration"><code>+ (uint16_t)portFromAddress:(NSData *)<em>address</em></code></div>
  655. </div>
  656. </div>
  657. <div class="section section-methods">
  658. <a title="Instance Methods" name="instance_methods"></a>
  659. <h2 class="subtitle subtitle-methods">Instance Methods</h2>
  660. <div class="section-method">
  661. <a name="//api/name/acceptOnInterface:port:error:" title="acceptOnInterface:port:error:"></a>
  662. <h3 class="subsubtitle method-title">acceptOnInterface:port:error:</h3>
  663. <div class="method-subsection brief-description">
  664. <p>This method is the same as <a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a> with the<br/>
  665. additional option of specifying which interface to listen on.</p>
  666. </div>
  667. <div class="method-subsection method-declaration"><code>- (BOOL)acceptOnInterface:(NSString *)<em>interface</em> port:(uint16_t)<em>port</em> error:(NSError **)<em>errPtr</em></code></div>
  668. <div class="method-subsection discussion-section">
  669. <h4 class="method-subtitle">Discussion</h4>
  670. <p>This method is the same as <a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a> with the<br/>
  671. additional option of specifying which interface to listen on.</p>
  672. <p>For example, you could specify that the socket should only accept connections over ethernet,<br/>
  673. and not other interfaces such as wifi.</p>
  674. <p>The interface may be specified by name (e.g. &ldquo;en1&rdquo; or &ldquo;lo0&rdquo;) or by IP address (e.g. &ldquo;192.168.4.34&rdquo;).<br/>
  675. You may also use the special strings &ldquo;localhost&rdquo; or &ldquo;loopback&rdquo; to specify that<br/>
  676. the socket only accept connections from the local machine.</p>
  677. <p>You can see the list of interfaces via the command line utility &ldquo;ifconfig&rdquo;,<br/>
  678. or programmatically via the getifaddrs() function.</p>
  679. <p>To accept connections on any interface pass nil, or simply use the <a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a> method.</p>
  680. </div>
  681. <div class="method-subsection declared-in-section">
  682. <h4 class="method-subtitle">Declared In</h4>
  683. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  684. </div>
  685. </div>
  686. <div class="section-method">
  687. <a name="//api/name/acceptOnPort:error:" title="acceptOnPort:error:"></a>
  688. <h3 class="subsubtitle method-title">acceptOnPort:error:</h3>
  689. <div class="method-subsection brief-description">
  690. <p>Tells the socket to begin listening and accepting connections on the given port.<br/>
  691. When a connection is accepted, a new instance of GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> will be spawned to handle it,<br/>
  692. and the socket:didAcceptNewSocket: <a href="#//api/name/delegate">delegate</a> method will be invoked.</p>
  693. </div>
  694. <div class="method-subsection method-declaration"><code>- (BOOL)acceptOnPort:(uint16_t)<em>port</em> error:(NSError **)<em>errPtr</em></code></div>
  695. <div class="method-subsection discussion-section">
  696. <h4 class="method-subtitle">Discussion</h4>
  697. <p>Tells the socket to begin listening and accepting connections on the given port.<br/>
  698. When a connection is accepted, a new instance of GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> will be spawned to handle it,<br/>
  699. and the socket:didAcceptNewSocket: <a href="#//api/name/delegate">delegate</a> method will be invoked.</p>
  700. <p>The socket will listen on all available interfaces (e.g. wifi, ethernet, etc)</p>
  701. </div>
  702. <div class="method-subsection declared-in-section">
  703. <h4 class="method-subtitle">Declared In</h4>
  704. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  705. </div>
  706. </div>
  707. <div class="section-method">
  708. <a name="//api/name/autoDisconnectOnClosedReadStream" title="autoDisconnectOnClosedReadStream"></a>
  709. <h3 class="subsubtitle method-title">autoDisconnectOnClosedReadStream</h3>
  710. <div class="method-subsection brief-description">
  711. <p>Traditionally sockets are not closed until the conversation is over.<br/>
  712. However, it is technically possible for the remote enpoint to close its write stream.<br/>
  713. Our socket would then be notified that there is no more data to be read,<br/>
  714. but our socket would still be writeable and the remote endpoint could continue to receive our data.</p>
  715. </div>
  716. <div class="method-subsection method-declaration"><code>- (BOOL)autoDisconnectOnClosedReadStream</code></div>
  717. <div class="method-subsection discussion-section">
  718. <h4 class="method-subtitle">Discussion</h4>
  719. <p>Traditionally sockets are not closed until the conversation is over.<br/>
  720. However, it is technically possible for the remote enpoint to close its write stream.<br/>
  721. Our socket would then be notified that there is no more data to be read,<br/>
  722. but our socket would still be writeable and the remote endpoint could continue to receive our data.</p>
  723. <p>The argument for this confusing functionality stems from the idea that a client could shut down its<br/>
  724. write stream after sending a request to the server, thus notifying the server there are to be no further requests.<br/>
  725. In practice, however, this technique did little to help server developers.</p>
  726. <p>To make matters worse, from a TCP perspective there is no way to tell the difference from a read stream close<br/>
  727. and a full socket close. They both result in the TCP stack receiving a FIN packet. The only way to tell<br/>
  728. is by continuing to write to the socket. If it was only a read stream close, then writes will continue to work.<br/>
  729. Otherwise an error will be occur shortly (when the remote end sends us a RST packet).</p>
  730. <p>In addition to the technical challenges and confusion, many high level socket/stream API&rsquo;s provide<br/>
  731. no support for dealing with the problem. If the read stream is closed, the API immediately declares the<br/>
  732. socket to be closed, and shuts down the write stream as well. In fact, this is what Apple&rsquo;s CFStream API does.<br/>
  733. It might sound like poor design at first, but in fact it simplifies development.</p>
  734. <p>The vast majority of the time if the read stream is closed it&rsquo;s because the remote endpoint closed its socket.<br/>
  735. Thus it actually makes sense to close the socket at this point.<br/>
  736. And in fact this is what most networking developers want and expect to happen.<br/>
  737. However, if you are writing a server that interacts with a plethora of clients,<br/>
  738. you might encounter a client that uses the discouraged technique of shutting down its write stream.<br/>
  739. If this is the case, you can set this property to NO,<br/>
  740. and make use of the socketDidCloseReadStream <a href="#//api/name/delegate">delegate</a> method.</p>
  741. <p>The default value is YES.</p>
  742. </div>
  743. <div class="method-subsection declared-in-section">
  744. <h4 class="method-subtitle">Declared In</h4>
  745. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  746. </div>
  747. </div>
  748. <div class="section-method">
  749. <a name="//api/name/connectToAddress:error:" title="connectToAddress:error:"></a>
  750. <h3 class="subsubtitle method-title">connectToAddress:error:</h3>
  751. <div class="method-subsection brief-description">
  752. <p>Connects to the given address, specified as a sockaddr structure wrapped in a NSData object.<br/>
  753. For example, a NSData object returned from NSNetService&rsquo;s addresses method.</p>
  754. </div>
  755. <div class="method-subsection method-declaration"><code>- (BOOL)connectToAddress:(NSData *)<em>remoteAddr</em> error:(NSError **)<em>errPtr</em></code></div>
  756. <div class="method-subsection discussion-section">
  757. <h4 class="method-subtitle">Discussion</h4>
  758. <p>Connects to the given address, specified as a sockaddr structure wrapped in a NSData object.<br/>
  759. For example, a NSData object returned from NSNetService&rsquo;s addresses method.</p>
  760. <p>If you have an existing struct sockaddr you can convert it to a NSData object like so:<br/>
  761. struct sockaddr sa -> NSData <em>dsa = [NSData dataWithBytes:&amp;remoteAddr length:remoteAddr.sa_len];<br/>
  762. struct sockaddr </em>sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len];</p>
  763. <p>This method invokes connectToAdd</p>
  764. </div>
  765. <div class="method-subsection declared-in-section">
  766. <h4 class="method-subtitle">Declared In</h4>
  767. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  768. </div>
  769. </div>
  770. <div class="section-method">
  771. <a name="//api/name/connectToAddress:viaInterface:withTimeout:error:" title="connectToAddress:viaInterface:withTimeout:error:"></a>
  772. <h3 class="subsubtitle method-title">connectToAddress:viaInterface:withTimeout:error:</h3>
  773. <div class="method-subsection brief-description">
  774. <p>Connects to the given address, using the specified interface and timeout.</p>
  775. </div>
  776. <div class="method-subsection method-declaration"><code>- (BOOL)connectToAddress:(NSData *)<em>remoteAddr</em> viaInterface:(NSString *)<em>interface</em> withTimeout:(NSTimeInterval)<em>timeout</em> error:(NSError **)<em>errPtr</em></code></div>
  777. <div class="method-subsection discussion-section">
  778. <h4 class="method-subtitle">Discussion</h4>
  779. <p>Connects to the given address, using the specified interface and timeout.</p>
  780. <p>The address is specified as a sockaddr structure wrapped in a NSData object.<br/>
  781. For example, a NSData object returned from NSNetService&rsquo;s addresses method.</p>
  782. <p>If you have an existing struct sockaddr you can convert it to a NSData object like so:<br/>
  783. struct sockaddr sa -> NSData <em>dsa = [NSData dataWithBytes:&amp;remoteAddr length:remoteAddr.sa_len];<br/>
  784. struct sockaddr </em>sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len];</p>
  785. <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/>
  786. The interface may also be used to specify the local port (see below).</p>
  787. <p>The timeout is optional. To not time out use a negative time interval.</p>
  788. <p>This method will return NO if an error is detected, and set the error pointer (if one was given).<br/>
  789. Possible errors would be a nil host, invalid interface, or socket is already connected.</p>
  790. <p>If no errors are detected, this method will start a background connect operation and immediately return YES.<br/>
  791. The <a href="#//api/name/delegate">delegate</a> callbacks are used to notify you when the socket connects, or if the host was unreachable.</p>
  792. <p>Since this class supports queued reads and writes, you can immediately start reading and/or writing.<br/>
  793. All read/write operations will be queued, and upon socket connection,<br/>
  794. the operations will be dequeued and processed in order.</p>
  795. <p>The interface may optionally contain a port number at the end of the string, separated by a colon.<br/>
  796. This allows you to specify the local port that should be used for the outgoing connection. (read paragraph to end)<br/>
  797. To specify both interface and local port: &ldquo;en1:8082&rdquo; or &ldquo;192.168.4.35:2424&rdquo;.<br/>
  798. To specify only local port: &ldquo;:8082&rdquo;.<br/>
  799. Please note this is an advanced feature, and is somewhat hidden on purpose.<br/>
  800. You should understand that 99.999% of the time you should NOT specify the local port for an outgoing connection.<br/>
  801. If you think you need to, there is a very good chance you have a fundamental misunderstanding somewhere.<br/>
  802. Local ports do NOT need to match remote ports. In fact, they almost never do.<br/>
  803. This feature is here for networking professionals using very advanced techniques.</p>
  804. </div>
  805. <div class="method-subsection declared-in-section">
  806. <h4 class="method-subtitle">Declared In</h4>
  807. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  808. </div>
  809. </div>
  810. <div class="section-method">
  811. <a name="//api/name/connectToAddress:withTimeout:error:" title="connectToAddress:withTimeout:error:"></a>
  812. <h3 class="subsubtitle method-title">connectToAddress:withTimeout:error:</h3>
  813. <div class="method-subsection brief-description">
  814. <p>This method is the same as <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> with an additional timeout option.<br/>
  815. To not time out use a negative time interval, or simply use the <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> method.</p>
  816. </div>
  817. <div class="method-subsection method-declaration"><code>- (BOOL)connectToAddress:(NSData *)<em>remoteAddr</em> withTimeout:(NSTimeInterval)<em>timeout</em> error:(NSError **)<em>errPtr</em></code></div>
  818. <div class="method-subsection discussion-section">
  819. <h4 class="method-subtitle">Discussion</h4>
  820. <p>This method is the same as <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> with an additional timeout option.<br/>
  821. To not time out use a negative time interval, or simply use the <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> method.</p>
  822. </div>
  823. <div class="method-subsection declared-in-section">
  824. <h4 class="method-subtitle">Declared In</h4>
  825. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  826. </div>
  827. </div>
  828. <div class="section-method">
  829. <a name="//api/name/connectToHost:onPort:error:" title="connectToHost:onPort:error:"></a>
  830. <h3 class="subsubtitle method-title">connectToHost:onPort:error:</h3>
  831. <div class="method-subsection brief-description">
  832. <p>Connects to the given host and port.</p>
  833. </div>
  834. <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>
  835. <div class="method-subsection discussion-section">
  836. <h4 class="method-subtitle">Discussion</h4>
  837. <p>Connects to the given host and port.</p>
  838. <p>This method invokes <a href="#//api/name/connectToHost:onPort:viaInterface:withTimeout:error:">connectToHost:onPort:viaInterface:withTimeout:error:</a><br/>
  839. and uses the default interface, and no timeout.</p>
  840. </div>
  841. <div class="method-subsection declared-in-section">
  842. <h4 class="method-subtitle">Declared In</h4>
  843. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  844. </div>
  845. </div>
  846. <div class="section-method">
  847. <a name="//api/name/connectToHost:onPort:viaInterface:withTimeout:error:" title="connectToHost:onPort:viaInterface:withTimeout:error:"></a>
  848. <h3 class="subsubtitle method-title">connectToHost:onPort:viaInterface:withTimeout:error:</h3>
  849. <div class="method-subsection brief-description">
  850. <p>Connects to the given host &amp; port, via the optional interface, with an optional timeout.</p>
  851. </div>
  852. <div class="method-subsection method-declaration"><code>- (BOOL)connectToHost:(NSString *)<em>host</em> onPort:(uint16_t)<em>port</em> viaInterface:(NSString *)<em>interface</em> withTimeout:(NSTimeInterval)<em>timeout</em> error:(NSError **)<em>errPtr</em></code></div>
  853. <div class="method-subsection discussion-section">
  854. <h4 class="method-subtitle">Discussion</h4>
  855. <p>Connects to the given host &amp; port, via the optional interface, with an optional timeout.</p>
  856. <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;).<br/>
  857. The host may also be the special strings &ldquo;localhost&rdquo; or &ldquo;loopback&rdquo; to specify connecting<br/>
  858. to a service on the local machine.</p>
  859. <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/>
  860. The interface may also be used to specify the local port (see below).</p>
  861. <p>To not time out use a negative time interval.</p>
  862. <p>This method will return NO if an error is detected, and set the error pointer (if one was given).<br/>
  863. Possible errors would be a nil host, invalid interface, or socket is already connected.</p>
  864. <p>If no errors are detected, this method will start a background connect operation and immediately return YES.<br/>
  865. The <a href="#//api/name/delegate">delegate</a> callbacks are used to notify you when the socket connects, or if the host was unreachable.</p>
  866. <p>Since this class supports queued reads and writes, you can immediately start reading and/or writing.<br/>
  867. All read/write operations will be queued, and upon socket connection,<br/>
  868. the operations will be dequeued and processed in order.</p>
  869. <p>The interface may optionally contain a port number at the end of the string, separated by a colon.<br/>
  870. This allows you to specify the local port that should be used for the outgoing connection. (read paragraph to end)<br/>
  871. To specify both interface and local port: &ldquo;en1:8082&rdquo; or &ldquo;192.168.4.35:2424&rdquo;.<br/>
  872. To specify only local port: &ldquo;:8082&rdquo;.<br/>
  873. Please note this is an advanced feature, and is somewhat hidden on purpose.<br/>
  874. You should understand that 99.999% of the time you should NOT specify the local port for an outgoing connection.<br/>
  875. If you think you need to, there is a very good chance you have a fundamental misunderstanding somewhere.<br/>
  876. Local ports do NOT need to match remote ports. In fact, they almost never do.<br/>
  877. This feature is here for networking professionals using very advanced techniques.</p>
  878. </div>
  879. <div class="method-subsection declared-in-section">
  880. <h4 class="method-subtitle">Declared In</h4>
  881. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  882. </div>
  883. </div>
  884. <div class="section-method">
  885. <a name="//api/name/connectToHost:onPort:withTimeout:error:" title="connectToHost:onPort:withTimeout:error:"></a>
  886. <h3 class="subsubtitle method-title">connectToHost:onPort:withTimeout:error:</h3>
  887. <div class="method-subsection brief-description">
  888. <p>Connects to the given host and port with an optional timeout.</p>
  889. </div>
  890. <div class="method-subsection method-declaration"><code>- (BOOL)connectToHost:(NSString *)<em>host</em> onPort:(uint16_t)<em>port</em> withTimeout:(NSTimeInterval)<em>timeout</em> error:(NSError **)<em>errPtr</em></code></div>
  891. <div class="method-subsection discussion-section">
  892. <h4 class="method-subtitle">Discussion</h4>
  893. <p>Connects to the given host and port with an optional timeout.</p>
  894. <p>This method invokes <a href="#//api/name/connectToHost:onPort:viaInterface:withTimeout:error:">connectToHost:onPort:viaInterface:withTimeout:error:</a> and uses the default interface.</p>
  895. </div>
  896. <div class="method-subsection declared-in-section">
  897. <h4 class="method-subtitle">Declared In</h4>
  898. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  899. </div>
  900. </div>
  901. <div class="section-method">
  902. <a name="//api/name/connectedAddress" title="connectedAddress"></a>
  903. <h3 class="subsubtitle method-title">connectedAddress</h3>
  904. <div class="method-subsection brief-description">
  905. <p>Returns the local or remote address to which this socket is connected,<br/>
  906. specified as a sockaddr structure wrapped in a NSData object.</p>
  907. </div>
  908. <div class="method-subsection method-declaration"><code>- (NSData *)connectedAddress</code></div>
  909. <div class="method-subsection discussion-section">
  910. <h4 class="method-subtitle">Discussion</h4>
  911. <p>Returns the local or remote address to which this socket is connected,<br/>
  912. specified as a sockaddr structure wrapped in a NSData object.</p>
  913. <p>See also the <a href="#//api/name/connectedHost">connectedHost</a>, <a href="#//api/name/connectedPort">connectedPort</a>, <a href="#//api/name/localHost">localHost</a> and <a href="#//api/name/localPort">localPort</a> methods.</p>
  914. </div>
  915. <div class="method-subsection declared-in-section">
  916. <h4 class="method-subtitle">Declared In</h4>
  917. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  918. </div>
  919. </div>
  920. <div class="section-method">
  921. <a name="//api/name/connectedHost" title="connectedHost"></a>
  922. <h3 class="subsubtitle method-title">connectedHost</h3>
  923. <div class="method-subsection brief-description">
  924. <p>Returns the local or remote host and port to which this socket is connected, or nil and 0 if not connected.<br/>
  925. The host will be an IP address.</p>
  926. </div>
  927. <div class="method-subsection method-declaration"><code>- (NSString *)connectedHost</code></div>
  928. <div class="method-subsection discussion-section">
  929. <h4 class="method-subtitle">Discussion</h4>
  930. <p>Returns the local or remote host and port to which this socket is connected, or nil and 0 if not connected.<br/>
  931. The host will be an IP address.</p>
  932. </div>
  933. <div class="method-subsection declared-in-section">
  934. <h4 class="method-subtitle">Declared In</h4>
  935. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  936. </div>
  937. </div>
  938. <div class="section-method">
  939. <a name="//api/name/connectedPort" title="connectedPort"></a>
  940. <h3 class="subsubtitle method-title">connectedPort</h3>
  941. <div class="method-subsection method-declaration"><code>- (uint16_t)connectedPort</code></div>
  942. </div>
  943. <div class="section-method">
  944. <a name="//api/name/delegate" title="delegate"></a>
  945. <h3 class="subsubtitle method-title">delegate</h3>
  946. <div class="method-subsection method-declaration"><code>- (id)delegate</code></div>
  947. </div>
  948. <div class="section-method">
  949. <a name="//api/name/delegateQueue" title="delegateQueue"></a>
  950. <h3 class="subsubtitle method-title">delegateQueue</h3>
  951. <div class="method-subsection method-declaration"><code>- (dispatch_queue_t)delegateQueue</code></div>
  952. </div>
  953. <div class="section-method">
  954. <a name="//api/name/disconnect" title="disconnect"></a>
  955. <h3 class="subsubtitle method-title">disconnect</h3>
  956. <div class="method-subsection brief-description">
  957. <p>Disconnects immediately (synchronously). Any pending reads or writes are dropped.</p>
  958. </div>
  959. <div class="method-subsection method-declaration"><code>- (void)disconnect</code></div>
  960. <div class="method-subsection discussion-section">
  961. <h4 class="method-subtitle">Discussion</h4>
  962. <p>Disconnects immediately (synchronously). Any pending reads or writes are dropped.</p>
  963. <p>If the socket is not already disconnected, an invocation to the socketDidDisconnect:withError: delegate method<br/>
  964. will be queued onto the delegateQueue asynchronously (behind any previously queued delegate methods).<br/>
  965. In other words, the disconnected delegate method will be invoked sometime shortly after this method returns.</p>
  966. <p>Please note the recommended way of releasing a GCDAsyncSocket instance (e.g. in a dealloc method)<br/>
  967. [asyncSocket setDelegate:nil];<br/>
  968. [asyncSocket disconnect];<br/>
  969. [asyncSocket release];</p>
  970. <p>If you plan on disconnecting the socket, and then immediately asking it to connect again,<br/>
  971. you&rsquo;ll likely want to do so like this:<br/>
  972. [asyncSocket setDelegate:nil];<br/>
  973. [asyncSocket disconnect];<br/>
  974. [asyncSocket setDelegate:self];<br/>
  975. [asyncSocket connect&hellip;];</p>
  976. </div>
  977. <div class="method-subsection declared-in-section">
  978. <h4 class="method-subtitle">Declared In</h4>
  979. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  980. </div>
  981. </div>
  982. <div class="section-method">
  983. <a name="//api/name/disconnectAfterReading" title="disconnectAfterReading"></a>
  984. <h3 class="subsubtitle method-title">disconnectAfterReading</h3>
  985. <div class="method-subsection brief-description">
  986. <p>Disconnects after all pending reads have completed.<br/>
  987. After calling this, the read and write methods will do nothing.<br/>
  988. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending writes.</p>
  989. </div>
  990. <div class="method-subsection method-declaration"><code>- (void)disconnectAfterReading</code></div>
  991. <div class="method-subsection discussion-section">
  992. <h4 class="method-subtitle">Discussion</h4>
  993. <p>Disconnects after all pending reads have completed.<br/>
  994. After calling this, the read and write methods will do nothing.<br/>
  995. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending writes.</p>
  996. </div>
  997. <div class="method-subsection declared-in-section">
  998. <h4 class="method-subtitle">Declared In</h4>
  999. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1000. </div>
  1001. </div>
  1002. <div class="section-method">
  1003. <a name="//api/name/disconnectAfterReadingAndWriting" title="disconnectAfterReadingAndWriting"></a>
  1004. <h3 class="subsubtitle method-title">disconnectAfterReadingAndWriting</h3>
  1005. <div class="method-subsection brief-description">
  1006. <p>Disconnects after all pending reads and writes have completed.<br/>
  1007. After calling this, the read and write methods will do nothing.</p>
  1008. </div>
  1009. <div class="method-subsection method-declaration"><code>- (void)disconnectAfterReadingAndWriting</code></div>
  1010. <div class="method-subsection discussion-section">
  1011. <h4 class="method-subtitle">Discussion</h4>
  1012. <p>Disconnects after all pending reads and writes have completed.<br/>
  1013. After calling this, the read and write methods will do nothing.</p>
  1014. </div>
  1015. <div class="method-subsection declared-in-section">
  1016. <h4 class="method-subtitle">Declared In</h4>
  1017. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1018. </div>
  1019. </div>
  1020. <div class="section-method">
  1021. <a name="//api/name/disconnectAfterWriting" title="disconnectAfterWriting"></a>
  1022. <h3 class="subsubtitle method-title">disconnectAfterWriting</h3>
  1023. <div class="method-subsection brief-description">
  1024. <p>Disconnects after all pending writes have completed.<br/>
  1025. After calling this, the read and write methods will do nothing.<br/>
  1026. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending reads.</p>
  1027. </div>
  1028. <div class="method-subsection method-declaration"><code>- (void)disconnectAfterWriting</code></div>
  1029. <div class="method-subsection discussion-section">
  1030. <h4 class="method-subtitle">Discussion</h4>
  1031. <p>Disconnects after all pending writes have completed.<br/>
  1032. After calling this, the read and write methods will do nothing.<br/>
  1033. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending reads.</p>
  1034. </div>
  1035. <div class="method-subsection declared-in-section">
  1036. <h4 class="method-subtitle">Declared In</h4>
  1037. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1038. </div>
  1039. </div>
  1040. <div class="section-method">
  1041. <a name="//api/name/enableBackgroundingOnSocket" title="enableBackgroundingOnSocket"></a>
  1042. <h3 class="subsubtitle method-title">enableBackgroundingOnSocket</h3>
  1043. <div class="method-subsection brief-description">
  1044. <p>This method is only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1045. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1046. </div>
  1047. <div class="method-subsection method-declaration"><code>- (BOOL)enableBackgroundingOnSocket</code></div>
  1048. <div class="method-subsection discussion-section">
  1049. <h4 class="method-subtitle">Discussion</h4>
  1050. <p>This method is only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1051. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1052. <p>Configures the socket to allow it to operate when the iOS application has been backgrounded.<br/>
  1053. In other words, this method creates a read &amp; write stream, and invokes:</p>
  1054. <p>CFReadStreamSetProperty(<a href="#//api/name/readStream">readStream</a>, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);<br/>
  1055. CFWriteStreamSetProperty(<a href="#//api/name/writeStream">writeStream</a>, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);</p>
  1056. <p>Returns YES if successful, NO otherwise.</p>
  1057. <p>Note: Apple does not officially support backgrounding server sockets.<br/>
  1058. That is, if your socket is accepting incoming connections, Apple does not officially support<br/>
  1059. allowing iOS applications to accept incoming connections while an app is backgrounded.</p>
  1060. <p>Example usage:</p>
  1061. <ul>
  1062. <li>(void)socket:(GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> <em>)sock didConnectToHost:(NSString </em>)host port:(uint16_t)port<br/>
  1063. {<br/>
  1064. [asyncSocket performBlock:^{<br/>
  1065. [asyncSocket enableBackgroundingOnSocket];<br/>
  1066. }];<br/>
  1067. }</li>
  1068. </ul>
  1069. </div>
  1070. <div class="method-subsection declared-in-section">
  1071. <h4 class="method-subtitle">Declared In</h4>
  1072. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1073. </div>
  1074. </div>
  1075. <div class="section-method">
  1076. <a name="//api/name/getDelegate:delegateQueue:" title="getDelegate:delegateQueue:"></a>
  1077. <h3 class="subsubtitle method-title">getDelegate:delegateQueue:</h3>
  1078. <div class="method-subsection method-declaration"><code>- (void)getDelegate:(id *)<em>delegatePtr</em> delegateQueue:(dispatch_queue_t *)<em>delegateQueuePtr</em></code></div>
  1079. </div>
  1080. <div class="section-method">
  1081. <a name="//api/name/init" title="init"></a>
  1082. <h3 class="subsubtitle method-title">init</h3>
  1083. <div class="method-subsection brief-description">
  1084. <p>GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> uses the standard <a href="#//api/name/delegate">delegate</a> paradigm,<br/>
  1085. but executes all <a href="#//api/name/delegate">delegate</a> callbacks on a given <a href="#//api/name/delegate">delegate</a> dispatch queue.<br/>
  1086. This allows for maximum concurrency, while at the same time providing easy thread safety.</p>
  1087. </div>
  1088. <div class="method-subsection method-declaration"><code>- (id)init</code></div>
  1089. <div class="method-subsection discussion-section">
  1090. <h4 class="method-subtitle">Discussion</h4>
  1091. <p>GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> uses the standard <a href="#//api/name/delegate">delegate</a> paradigm,<br/>
  1092. but executes all <a href="#//api/name/delegate">delegate</a> callbacks on a given <a href="#//api/name/delegate">delegate</a> dispatch queue.<br/>
  1093. This allows for maximum concurrency, while at the same time providing easy thread safety.</p>
  1094. <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/>
  1095. use the socket, or you will get an error.</p>
  1096. <p>The socket queue is optional.<br/>
  1097. If you pass NULL, GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> will automatically create it&rsquo;s own socket queue.<br/>
  1098. If you choose to provide a socket queue, the socket queue must not be a concurrent queue.</p>
  1099. <p>The <a href="#//api/name/delegate">delegate</a> queue and socket queue can optionally be the same.</p>
  1100. </div>
  1101. <div class="method-subsection declared-in-section">
  1102. <h4 class="method-subtitle">Declared In</h4>
  1103. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1104. </div>
  1105. </div>
  1106. <div class="section-method">
  1107. <a name="//api/name/initWithDelegate:delegateQueue:" title="initWithDelegate:delegateQueue:"></a>
  1108. <h3 class="subsubtitle method-title">initWithDelegate:delegateQueue:</h3>
  1109. <div class="method-subsection method-declaration"><code>- (id)initWithDelegate:(id)<em>aDelegate</em> delegateQueue:(dispatch_queue_t)<em>dq</em></code></div>
  1110. </div>
  1111. <div class="section-method">
  1112. <a name="//api/name/initWithDelegate:delegateQueue:socketQueue:" title="initWithDelegate:delegateQueue:socketQueue:"></a>
  1113. <h3 class="subsubtitle method-title">initWithDelegate:delegateQueue:socketQueue:</h3>
  1114. <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>
  1115. </div>
  1116. <div class="section-method">
  1117. <a name="//api/name/initWithSocketQueue:" title="initWithSocketQueue:"></a>
  1118. <h3 class="subsubtitle method-title">initWithSocketQueue:</h3>
  1119. <div class="method-subsection method-declaration"><code>- (id)initWithSocketQueue:(dispatch_queue_t)<em>sq</em></code></div>
  1120. </div>
  1121. <div class="section-method">
  1122. <a name="//api/name/isConnected" title="isConnected"></a>
  1123. <h3 class="subsubtitle method-title">isConnected</h3>
  1124. <div class="method-subsection method-declaration"><code>- (BOOL)isConnected</code></div>
  1125. </div>
  1126. <div class="section-method">
  1127. <a name="//api/name/isDisconnected" title="isDisconnected"></a>
  1128. <h3 class="subsubtitle method-title">isDisconnected</h3>
  1129. <div class="method-subsection brief-description">
  1130. <p>Returns whether the socket is disconnected or connected.</p>
  1131. </div>
  1132. <div class="method-subsection method-declaration"><code>- (BOOL)isDisconnected</code></div>
  1133. <div class="method-subsection discussion-section">
  1134. <h4 class="method-subtitle">Discussion</h4>
  1135. <p>Returns whether the socket is disconnected or connected.</p>
  1136. <p>A disconnected socket may be recycled.<br/>
  1137. That is, it can used again for connecting or listening.</p>
  1138. <p>If a socket is in the process of connecting, it may be neither disconnected nor connected.</p>
  1139. </div>
  1140. <div class="method-subsection declared-in-section">
  1141. <h4 class="method-subtitle">Declared In</h4>
  1142. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1143. </div>
  1144. </div>
  1145. <div class="section-method">
  1146. <a name="//api/name/isIPv4" title="isIPv4"></a>
  1147. <h3 class="subsubtitle method-title">isIPv4</h3>
  1148. <div class="method-subsection brief-description">
  1149. <p>Returns whether the socket is IPv4 or IPv6.<br/>
  1150. An accepting socket may be both.</p>
  1151. </div>
  1152. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv4</code></div>
  1153. <div class="method-subsection discussion-section">
  1154. <h4 class="method-subtitle">Discussion</h4>
  1155. <p>Returns whether the socket is IPv4 or IPv6.<br/>
  1156. An accepting socket may be both.</p>
  1157. </div>
  1158. <div class="method-subsection declared-in-section">
  1159. <h4 class="method-subtitle">Declared In</h4>
  1160. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1161. </div>
  1162. </div>
  1163. <div class="section-method">
  1164. <a name="//api/name/isIPv4Enabled" title="isIPv4Enabled"></a>
  1165. <h3 class="subsubtitle method-title">isIPv4Enabled</h3>
  1166. <div class="method-subsection brief-description">
  1167. <p>By default, both IPv4 and IPv6 are enabled.</p>
  1168. </div>
  1169. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv4Enabled</code></div>
  1170. <div class="method-subsection discussion-section">
  1171. <h4 class="method-subtitle">Discussion</h4>
  1172. <p>By default, both IPv4 and IPv6 are enabled.</p>
  1173. <p>For accepting incoming connections, this means GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> automatically supports both protocols,<br/>
  1174. and can simulataneously accept incoming connections on either protocol.</p>
  1175. <p>For outgoing connections, this means GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> can connect to remote hosts running either protocol.<br/>
  1176. If a DNS lookup returns only IPv4 results, GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> will automatically use IPv4.<br/>
  1177. If a DNS lookup returns only IPv6 results, GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> will automatically use IPv6.<br/>
  1178. If a DNS lookup returns both IPv4 and IPv6 results, the preferred protocol will be chosen.<br/>
  1179. By default, the preferred protocol is IPv4, but may be configured as desired.</p>
  1180. </div>
  1181. <div class="method-subsection declared-in-section">
  1182. <h4 class="method-subtitle">Declared In</h4>
  1183. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1184. </div>
  1185. </div>
  1186. <div class="section-method">
  1187. <a name="//api/name/isIPv4PreferredOverIPv6" title="isIPv4PreferredOverIPv6"></a>
  1188. <h3 class="subsubtitle method-title">isIPv4PreferredOverIPv6</h3>
  1189. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv4PreferredOverIPv6</code></div>
  1190. </div>
  1191. <div class="section-method">
  1192. <a name="//api/name/isIPv6" title="isIPv6"></a>
  1193. <h3 class="subsubtitle method-title">isIPv6</h3>
  1194. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv6</code></div>
  1195. </div>
  1196. <div class="section-method">
  1197. <a name="//api/name/isIPv6Enabled" title="isIPv6Enabled"></a>
  1198. <h3 class="subsubtitle method-title">isIPv6Enabled</h3>
  1199. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv6Enabled</code></div>
  1200. </div>
  1201. <div class="section-method">
  1202. <a name="//api/name/isSecure" title="isSecure"></a>
  1203. <h3 class="subsubtitle method-title">isSecure</h3>
  1204. <div class="method-subsection brief-description">
  1205. <p>Returns whether or not the socket has been secured via SSL/TLS.</p>
  1206. </div>
  1207. <div class="method-subsection method-declaration"><code>- (BOOL)isSecure</code></div>
  1208. <div class="method-subsection discussion-section">
  1209. <h4 class="method-subtitle">Discussion</h4>
  1210. <p>Returns whether or not the socket has been secured via SSL/TLS.</p>
  1211. <p>See also the startTLS method.</p>
  1212. </div>
  1213. <div class="method-subsection declared-in-section">
  1214. <h4 class="method-subtitle">Declared In</h4>
  1215. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1216. </div>
  1217. </div>
  1218. <div class="section-method">
  1219. <a name="//api/name/localAddress" title="localAddress"></a>
  1220. <h3 class="subsubtitle method-title">localAddress</h3>
  1221. <div class="method-subsection method-declaration"><code>- (NSData *)localAddress</code></div>
  1222. </div>
  1223. <div class="section-method">
  1224. <a name="//api/name/localHost" title="localHost"></a>
  1225. <h3 class="subsubtitle method-title">localHost</h3>
  1226. <div class="method-subsection method-declaration"><code>- (NSString *)localHost</code></div>
  1227. </div>
  1228. <div class="section-method">
  1229. <a name="//api/name/localPort" title="localPort"></a>
  1230. <h3 class="subsubtitle method-title">localPort</h3>
  1231. <div class="method-subsection method-declaration"><code>- (uint16_t)localPort</code></div>
  1232. </div>
  1233. <div class="section-method">
  1234. <a name="//api/name/performBlock:" title="performBlock:"></a>
  1235. <h3 class="subsubtitle method-title">performBlock:</h3>
  1236. <div class="method-subsection brief-description">
  1237. <p>It&rsquo;s not thread-safe to access certain variables from outside the socket&rsquo;s internal queue.</p>
  1238. </div>
  1239. <div class="method-subsection method-declaration"><code>- (void)performBlock:(dispatch_block_t)<em>block</em></code></div>
  1240. <div class="method-subsection discussion-section">
  1241. <h4 class="method-subtitle">Discussion</h4>
  1242. <p>It&rsquo;s not thread-safe to access certain variables from outside the socket&rsquo;s internal queue.</p>
  1243. <p>For example, the socket file descriptor.<br/>
  1244. File descriptors are simply integers which reference an index in the per-process file table.<br/>
  1245. However, when one requests a new file descriptor (by opening a file or socket),<br/>
  1246. the file descriptor returned is guaranteed to be the lowest numbered unused descriptor.<br/>
  1247. So if we&rsquo;re not careful, the following could be possible:</p>
  1248. <ul>
  1249. <li>Thread A invokes a method which returns the socket&rsquo;s file descriptor.</li>
  1250. <li>The socket is closed via the socket&rsquo;s internal queue on thread B.</li>
  1251. <li>Thread C opens a file, and subsequently receives the file descriptor that was previously the socket&rsquo;s FD.</li>
  1252. <li>Thread A is now accessing/altering the file instead of the socket.</li>
  1253. </ul>
  1254. <p>In addition to this, other variables are not actually objects,<br/>
  1255. and thus cannot be retained/released or even autoreleased.<br/>
  1256. An example is the <a href="#//api/name/sslContext">sslContext</a>, of type SSLContextRef, which is actually a malloc&rsquo;d struct.</p>
  1257. <p>Although there are internal variables that make it difficult to maintain thread-safety,<br/>
  1258. it is important to provide access to these variables<br/>
  1259. to ensure this class can be used in a wide array of environments.<br/>
  1260. This method helps to accomplish this by invoking the current block on the socket&rsquo;s internal queue.<br/>
  1261. The methods below can be invoked from within the block to access<br/>
  1262. those generally thread-unsafe internal variables in a thread-safe manner.<br/>
  1263. The given block will be invoked synchronously on the socket&rsquo;s internal queue.</p>
  1264. <p>If you save references to any protected variables and use them outside the block, you do so at your own peril.</p>
  1265. </div>
  1266. <div class="method-subsection declared-in-section">
  1267. <h4 class="method-subtitle">Declared In</h4>
  1268. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1269. </div>
  1270. </div>
  1271. <div class="section-method">
  1272. <a name="//api/name/progressOfReadReturningTag:bytesDone:total:" title="progressOfReadReturningTag:bytesDone:total:"></a>
  1273. <h3 class="subsubtitle method-title">progressOfReadReturningTag:bytesDone:total:</h3>
  1274. <div class="method-subsection brief-description">
  1275. <p>Returns progress of the current read, from 0.0 to 1.0, or NaN if no current read (use isnan() to check).<br/>
  1276. The parameters &ldquo;tag&rdquo;, &ldquo;done&rdquo; and &ldquo;total&rdquo; will be filled in if they aren&rsquo;t NULL.</p>
  1277. </div>
  1278. <div class="method-subsection method-declaration"><code>- (float)progressOfReadReturningTag:(long *)<em>tagPtr</em> bytesDone:(NSUInteger *)<em>donePtr</em> total:(NSUInteger *)<em>totalPtr</em></code></div>
  1279. <div class="method-subsection discussion-section">
  1280. <h4 class="method-subtitle">Discussion</h4>
  1281. <p>Returns progress of the current read, from 0.0 to 1.0, or NaN if no current read (use isnan() to check).<br/>
  1282. The parameters &ldquo;tag&rdquo;, &ldquo;done&rdquo; and &ldquo;total&rdquo; will be filled in if they aren&rsquo;t NULL.</p>
  1283. </div>
  1284. <div class="method-subsection declared-in-section">
  1285. <h4 class="method-subtitle">Declared In</h4>
  1286. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1287. </div>
  1288. </div>
  1289. <div class="section-method">
  1290. <a name="//api/name/progressOfWriteReturningTag:bytesDone:total:" title="progressOfWriteReturningTag:bytesDone:total:"></a>
  1291. <h3 class="subsubtitle method-title">progressOfWriteReturningTag:bytesDone:total:</h3>
  1292. <div class="method-subsection brief-description">
  1293. <p>Returns progress of the current write, from 0.0 to 1.0, or NaN if no current write (use isnan() to check).<br/>
  1294. The parameters &ldquo;tag&rdquo;, &ldquo;done&rdquo; and &ldquo;total&rdquo; will be filled in if they aren&rsquo;t NULL.</p>
  1295. </div>
  1296. <div class="method-subsection method-declaration"><code>- (float)progressOfWriteReturningTag:(long *)<em>tagPtr</em> bytesDone:(NSUInteger *)<em>donePtr</em> total:(NSUInteger *)<em>totalPtr</em></code></div>
  1297. <div class="method-subsection discussion-section">
  1298. <h4 class="method-subtitle">Discussion</h4>
  1299. <p>Returns progress of the current write, from 0.0 to 1.0, or NaN if no current write (use isnan() to check).<br/>
  1300. The parameters &ldquo;tag&rdquo;, &ldquo;done&rdquo; and &ldquo;total&rdquo; will be filled in if they aren&rsquo;t NULL.</p>
  1301. </div>
  1302. <div class="method-subsection declared-in-section">
  1303. <h4 class="method-subtitle">Declared In</h4>
  1304. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1305. </div>
  1306. </div>
  1307. <div class="section-method">
  1308. <a name="//api/name/readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:" title="readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:"></a>
  1309. <h3 class="subsubtitle method-title">readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:</h3>
  1310. <div class="method-subsection brief-description">
  1311. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  1312. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1313. The given buffer will automatically be increased in size if needed.</p>
  1314. </div>
  1315. <div class="method-subsection method-declaration"><code>- (void)readDataToData:(NSData *)<em>data</em> withTimeout:(NSTimeInterval)<em>timeout</em> buffer:(NSMutableData *)<em>buffer</em> bufferOffset:(NSUInteger)<em>offset</em> maxLength:(NSUInteger)<em>length</em> tag:(long)<em>tag</em></code></div>
  1316. <div class="method-subsection discussion-section">
  1317. <h4 class="method-subtitle">Discussion</h4>
  1318. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  1319. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1320. The given buffer will automatically be increased in size if needed.</p>
  1321. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  1322. If the buffer if nil, a buffer will automatically be created for you.</p>
  1323. <p>If maxLength is zero, no length restriction is enforced.<br/>
  1324. Otherwise if maxLength bytes are read without completing the read,<br/>
  1325. it is treated similarly to a timeout - the socket is closed with a GCDAsyncSocketReadMaxedOutError.<br/>
  1326. The read will complete successfully if exactly maxLength bytes are read and the given data is found at the end.</p>
  1327. <p>If you pass a maxLength parameter that is less than the length of the data (separator) parameter,<br/>
  1328. the method will do nothing (except maybe print a warning), and the delegate will not be called.<br/>
  1329. If the bufferOffset is greater than the length of the given buffer,<br/>
  1330. the method will do nothing (except maybe print a warning), and the delegate will not be called.</p>
  1331. <p>If you pass a buffer, you must not alter it in any way while the socket is using it.<br/>
  1332. After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer.<br/>
  1333. That is, it will reference the bytes that were appended to the given buffer via<br/>
  1334. the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO].</p>
  1335. <p>To read a line from the socket, use the line separator (e.g. CRLF for HTTP, see below) as the &ldquo;data&rdquo; parameter.<br/>
  1336. If you&rsquo;re developing your own custom protocol, be sure your separator can not occur naturally as<br/>
  1337. part of the data between separators.<br/>
  1338. For example, imagine you want to send several small documents over a socket.<br/>
  1339. Using CRLF as a separator is likely unwise, as a CRLF could easily exist within the documents.<br/>
  1340. In this particular example, it would be better to use a protocol similar to HTTP with<br/>
  1341. a header that includes the length of the document.<br/>
  1342. Also be careful that your separator cannot occur naturally as part of the encoding for a character.</p>
  1343. <p>The given data (separator) parameter should be immutable.<br/>
  1344. For performance reasons, the socket will retain it, not copy it.<br/>
  1345. So if it is immutable, don&rsquo;t modify it while the socket is using it.</p>
  1346. </div>
  1347. <div class="method-subsection declared-in-section">
  1348. <h4 class="method-subtitle">Declared In</h4>
  1349. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1350. </div>
  1351. </div>
  1352. <div class="section-method">
  1353. <a name="//api/name/readDataToData:withTimeout:buffer:bufferOffset:tag:" title="readDataToData:withTimeout:buffer:bufferOffset:tag:"></a>
  1354. <h3 class="subsubtitle method-title">readDataToData:withTimeout:buffer:bufferOffset:tag:</h3>
  1355. <div class="method-subsection brief-description">
  1356. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  1357. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1358. The given buffer will automatically be increased in size if needed.</p>
  1359. </div>
  1360. <div class="method-subsection method-declaration"><code>- (void)readDataToData:(NSData *)<em>data</em> withTimeout:(NSTimeInterval)<em>timeout</em> buffer:(NSMutableData *)<em>buffer</em> bufferOffset:(NSUInteger)<em>offset</em> tag:(long)<em>tag</em></code></div>
  1361. <div class="method-subsection discussion-section">
  1362. <h4 class="method-subtitle">Discussion</h4>
  1363. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  1364. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1365. The given buffer will automatically be increased in size if needed.</p>
  1366. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  1367. If the buffer if nil, a buffer will automatically be created for you.</p>
  1368. <p>If the bufferOffset is greater than the length of the given buffer,<br/>
  1369. the method will do nothing (except maybe print a warning), and the delegate will not be called.</p>
  1370. <p>If you pass a buffer, you must not alter it in any way while the socket is using it.<br/>
  1371. After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer.<br/>
  1372. That is, it will reference the bytes that were appended to the given buffer via<br/>
  1373. the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO].</p>
  1374. <p>To read a line from the socket, use the line separator (e.g. CRLF for HTTP, see below) as the &ldquo;data&rdquo; parameter.<br/>
  1375. If you&rsquo;re developing your own custom protocol, be sure your separator can not occur naturally as<br/>
  1376. part of the data between separators.<br/>
  1377. For example, imagine you want to send several small documents over a socket.<br/>
  1378. Using CRLF as a separator is likely unwise, as a CRLF could easily exist within the documents.<br/>
  1379. In this particular example, it would be better to use a protocol similar to HTTP with<br/>
  1380. a header that includes the length of the document.<br/>
  1381. Also be careful that your separator cannot occur naturally as part of the encoding for a character.</p>
  1382. <p>The given data (separator) parameter should be immutable.<br/>
  1383. For performance reasons, the socket will retain it, not copy it.<br/>
  1384. So if it is immutable, don&rsquo;t modify it while the socket is using it.</p>
  1385. </div>
  1386. <div class="method-subsection declared-in-section">
  1387. <h4 class="method-subtitle">Declared In</h4>
  1388. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1389. </div>
  1390. </div>
  1391. <div class="section-method">
  1392. <a name="//api/name/readDataToData:withTimeout:maxLength:tag:" title="readDataToData:withTimeout:maxLength:tag:"></a>
  1393. <h3 class="subsubtitle method-title">readDataToData:withTimeout:maxLength:tag:</h3>
  1394. <div class="method-subsection brief-description">
  1395. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p>
  1396. </div>
  1397. <div class="method-subsection method-declaration"><code>- (void)readDataToData:(NSData *)<em>data</em> withTimeout:(NSTimeInterval)<em>timeout</em> maxLength:(NSUInteger)<em>length</em> tag:(long)<em>tag</em></code></div>
  1398. <div class="method-subsection discussion-section">
  1399. <h4 class="method-subtitle">Discussion</h4>
  1400. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p>
  1401. <p>If the timeout value is negative, the read operation will not use a timeout.</p>
  1402. <p>If maxLength is zero, no length restriction is enforced.<br/>
  1403. Otherwise if maxLength bytes are read without completing the read,<br/>
  1404. it is treated similarly to a timeout - the socket is closed with a GCDAsyncSocketReadMaxedOutError.<br/>
  1405. The read will complete successfully if exactly maxLength bytes are read and the given data is found at the end.</p>
  1406. <p>If you pass nil or zero-length data as the &ldquo;data&rdquo; parameter,<br/>
  1407. the method will do nothing (except maybe print a warning), and the <a href="#//api/name/delegate">delegate</a> will not be called.<br/>
  1408. If you pass a maxLength parameter that is less than the length of the data parameter,<br/>
  1409. the method will do nothing (except maybe print a warning), and the <a href="#//api/name/delegate">delegate</a> will not be called.</p>
  1410. <p>To read a line from the socket, use the line separator (e.g. CRLF for HTTP, see below) as the &ldquo;data&rdquo; parameter.<br/>
  1411. If you&rsquo;re developing your own custom protocol, be sure your separator can not occur naturally as<br/>
  1412. part of the data between separators.<br/>
  1413. For example, imagine you want to send several small documents over a socket.<br/>
  1414. Using CRLF as a separator is likely unwise, as a CRLF could easily exist within the documents.<br/>
  1415. In this particular example, it would be better to use a protocol similar to HTTP with<br/>
  1416. a header that includes the length of the document.<br/>
  1417. Also be careful that your separator cannot occur naturally as part of the encoding for a character.</p>
  1418. <p>The given data (separator) parameter should be immutable.<br/>
  1419. For performance reasons, the socket will retain it, not copy it.<br/>
  1420. So if it is immutable, don&rsquo;t modify it while the socket is using it.</p>
  1421. </div>
  1422. <div class="method-subsection declared-in-section">
  1423. <h4 class="method-subtitle">Declared In</h4>
  1424. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1425. </div>
  1426. </div>
  1427. <div class="section-method">
  1428. <a name="//api/name/readDataToData:withTimeout:tag:" title="readDataToData:withTimeout:tag:"></a>
  1429. <h3 class="subsubtitle method-title">readDataToData:withTimeout:tag:</h3>
  1430. <div class="method-subsection brief-description">
  1431. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p>
  1432. </div>
  1433. <div class="method-subsection method-declaration"><code>- (void)readDataToData:(NSData *)<em>data</em> withTimeout:(NSTimeInterval)<em>timeout</em> tag:(long)<em>tag</em></code></div>
  1434. <div class="method-subsection discussion-section">
  1435. <h4 class="method-subtitle">Discussion</h4>
  1436. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p>
  1437. <p>If the timeout value is negative, the read operation will not use a timeout.</p>
  1438. <p>If you pass nil or zero-length data as the &ldquo;data&rdquo; parameter,<br/>
  1439. the method will do nothing (except maybe print a warning), and the <a href="#//api/name/delegate">delegate</a> will not be called.</p>
  1440. <p>To read a line from the socket, use the line separator (e.g. CRLF for HTTP, see below) as the &ldquo;data&rdquo; parameter.<br/>
  1441. If you&rsquo;re developing your own custom protocol, be sure your separator can not occur naturally as<br/>
  1442. part of the data between separators.<br/>
  1443. For example, imagine you want to send several small documents over a socket.<br/>
  1444. Using CRLF as a separator is likely unwise, as a CRLF could easily exist within the documents.<br/>
  1445. In this particular example, it would be better to use a protocol similar to HTTP with<br/>
  1446. a header that includes the length of the document.<br/>
  1447. Also be careful that your separator cannot occur naturally as part of the encoding for a character.</p>
  1448. <p>The given data (separator) parameter should be immutable.<br/>
  1449. For performance reasons, the socket will retain it, not copy it.<br/>
  1450. So if it is immutable, don&rsquo;t modify it while the socket is using it.</p>
  1451. </div>
  1452. <div class="method-subsection declared-in-section">
  1453. <h4 class="method-subtitle">Declared In</h4>
  1454. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1455. </div>
  1456. </div>
  1457. <div class="section-method">
  1458. <a name="//api/name/readDataToLength:withTimeout:buffer:bufferOffset:tag:" title="readDataToLength:withTimeout:buffer:bufferOffset:tag:"></a>
  1459. <h3 class="subsubtitle method-title">readDataToLength:withTimeout:buffer:bufferOffset:tag:</h3>
  1460. <div class="method-subsection brief-description">
  1461. <p>Reads the given number of bytes.<br/>
  1462. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1463. The given buffer will automatically be increased in size if needed.</p>
  1464. </div>
  1465. <div class="method-subsection method-declaration"><code>- (void)readDataToLength:(NSUInteger)<em>length</em> withTimeout:(NSTimeInterval)<em>timeout</em> buffer:(NSMutableData *)<em>buffer</em> bufferOffset:(NSUInteger)<em>offset</em> tag:(long)<em>tag</em></code></div>
  1466. <div class="method-subsection discussion-section">
  1467. <h4 class="method-subtitle">Discussion</h4>
  1468. <p>Reads the given number of bytes.<br/>
  1469. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1470. The given buffer will automatically be increased in size if needed.</p>
  1471. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  1472. If the buffer if nil, a buffer will automatically be created for you.</p>
  1473. <p>If the length is 0, this method does nothing and the delegate is not called.<br/>
  1474. If the bufferOffset is greater than the length of the given buffer,<br/>
  1475. the method will do nothing, and the delegate will not be called.</p>
  1476. <p>If you pass a buffer, you must not alter it in any way while AsyncSocket is using it.<br/>
  1477. After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer.<br/>
  1478. That is, it will reference the bytes that were appended to the given buffer via<br/>
  1479. the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO].</p>
  1480. </div>
  1481. <div class="method-subsection declared-in-section">
  1482. <h4 class="method-subtitle">Declared In</h4>
  1483. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1484. </div>
  1485. </div>
  1486. <div class="section-method">
  1487. <a name="//api/name/readDataToLength:withTimeout:tag:" title="readDataToLength:withTimeout:tag:"></a>
  1488. <h3 class="subsubtitle method-title">readDataToLength:withTimeout:tag:</h3>
  1489. <div class="method-subsection brief-description">
  1490. <p>Reads the given number of bytes.</p>
  1491. </div>
  1492. <div class="method-subsection method-declaration"><code>- (void)readDataToLength:(NSUInteger)<em>length</em> withTimeout:(NSTimeInterval)<em>timeout</em> tag:(long)<em>tag</em></code></div>
  1493. <div class="method-subsection discussion-section">
  1494. <h4 class="method-subtitle">Discussion</h4>
  1495. <p>Reads the given number of bytes.</p>
  1496. <p>If the timeout value is negative, the read operation will not use a timeout.</p>
  1497. <p>If the length is 0, this method does nothing and the <a href="#//api/name/delegate">delegate</a> is not called.</p>
  1498. </div>
  1499. <div class="method-subsection declared-in-section">
  1500. <h4 class="method-subtitle">Declared In</h4>
  1501. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1502. </div>
  1503. </div>
  1504. <div class="section-method">
  1505. <a name="//api/name/readDataWithTimeout:buffer:bufferOffset:maxLength:tag:" title="readDataWithTimeout:buffer:bufferOffset:maxLength:tag:"></a>
  1506. <h3 class="subsubtitle method-title">readDataWithTimeout:buffer:bufferOffset:maxLength:tag:</h3>
  1507. <div class="method-subsection brief-description">
  1508. <p>Reads the first available bytes that become available on the socket.<br/>
  1509. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1510. The given buffer will automatically be increased in size if needed.<br/>
  1511. A maximum of length bytes will be read.</p>
  1512. </div>
  1513. <div class="method-subsection method-declaration"><code>- (void)readDataWithTimeout:(NSTimeInterval)<em>timeout</em> buffer:(NSMutableData *)<em>buffer</em> bufferOffset:(NSUInteger)<em>offset</em> maxLength:(NSUInteger)<em>length</em> tag:(long)<em>tag</em></code></div>
  1514. <div class="method-subsection discussion-section">
  1515. <h4 class="method-subtitle">Discussion</h4>
  1516. <p>Reads the first available bytes that become available on the socket.<br/>
  1517. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1518. The given buffer will automatically be increased in size if needed.<br/>
  1519. A maximum of length bytes will be read.</p>
  1520. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  1521. If the buffer if nil, a buffer will automatically be created for you.<br/>
  1522. If maxLength is zero, no length restriction is enforced.</p>
  1523. <p>If the bufferOffset is greater than the length of the given buffer,<br/>
  1524. the method will do nothing, and the delegate will not be called.</p>
  1525. <p>If you pass a buffer, you must not alter it in any way while the socket is using it.<br/>
  1526. After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer.<br/>
  1527. That is, it will reference the bytes that were appended to the given buffer via<br/>
  1528. the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO].</p>
  1529. </div>
  1530. <div class="method-subsection declared-in-section">
  1531. <h4 class="method-subtitle">Declared In</h4>
  1532. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1533. </div>
  1534. </div>
  1535. <div class="section-method">
  1536. <a name="//api/name/readDataWithTimeout:buffer:bufferOffset:tag:" title="readDataWithTimeout:buffer:bufferOffset:tag:"></a>
  1537. <h3 class="subsubtitle method-title">readDataWithTimeout:buffer:bufferOffset:tag:</h3>
  1538. <div class="method-subsection brief-description">
  1539. <p>Reads the first available bytes that become available on the socket.<br/>
  1540. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1541. The given buffer will automatically be increased in size if needed.</p>
  1542. </div>
  1543. <div class="method-subsection method-declaration"><code>- (void)readDataWithTimeout:(NSTimeInterval)<em>timeout</em> buffer:(NSMutableData *)<em>buffer</em> bufferOffset:(NSUInteger)<em>offset</em> tag:(long)<em>tag</em></code></div>
  1544. <div class="method-subsection discussion-section">
  1545. <h4 class="method-subtitle">Discussion</h4>
  1546. <p>Reads the first available bytes that become available on the socket.<br/>
  1547. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1548. The given buffer will automatically be increased in size if needed.</p>
  1549. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  1550. If the buffer if nil, the socket will create a buffer for you.</p>
  1551. <p>If the bufferOffset is greater than the length of the given buffer,<br/>
  1552. the method will do nothing, and the delegate will not be called.</p>
  1553. <p>If you pass a buffer, you must not alter it in any way while the socket is using it.<br/>
  1554. After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer.<br/>
  1555. That is, it will reference the bytes that were appended to the given buffer via<br/>
  1556. the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO].</p>
  1557. </div>
  1558. <div class="method-subsection declared-in-section">
  1559. <h4 class="method-subtitle">Declared In</h4>
  1560. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1561. </div>
  1562. </div>
  1563. <div class="section-method">
  1564. <a name="//api/name/readDataWithTimeout:tag:" title="readDataWithTimeout:tag:"></a>
  1565. <h3 class="subsubtitle method-title">readDataWithTimeout:tag:</h3>
  1566. <div class="method-subsection brief-description">
  1567. <p>Reads the first available bytes that become available on the socket.</p>
  1568. </div>
  1569. <div class="method-subsection method-declaration"><code>- (void)readDataWithTimeout:(NSTimeInterval)<em>timeout</em> tag:(long)<em>tag</em></code></div>
  1570. <div class="method-subsection discussion-section">
  1571. <h4 class="method-subtitle">Discussion</h4>
  1572. <p>Reads the first available bytes that become available on the socket.</p>
  1573. <p>If the timeout value is negative, the read operation will not use a timeout.</p>
  1574. </div>
  1575. <div class="method-subsection declared-in-section">
  1576. <h4 class="method-subtitle">Declared In</h4>
  1577. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1578. </div>
  1579. </div>
  1580. <div class="section-method">
  1581. <a name="//api/name/readStream" title="readStream"></a>
  1582. <h3 class="subsubtitle method-title">readStream</h3>
  1583. <div class="method-subsection brief-description">
  1584. <p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1585. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1586. </div>
  1587. <div class="method-subsection method-declaration"><code>- (CFReadStreamRef)readStream</code></div>
  1588. <div class="method-subsection discussion-section">
  1589. <h4 class="method-subtitle">Discussion</h4>
  1590. <p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1591. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1592. <p>Provides access to the socket&rsquo;s internal CFReadStream/CFWriteStream.</p>
  1593. <p>These streams are only used as workarounds for specific iOS shortcomings:</p>
  1594. <ul>
  1595. <li><p>Apple has decided to keep the SecureTransport framework private is iOS.<br/>
  1596. This means the only supplied way to do SSL/TLS is via CFStream or some other API layered on top of it.<br/>
  1597. Thus, in order to provide SSL/TLS support on iOS we are forced to rely on CFStream,<br/>
  1598. instead of the preferred and faster and more powerful SecureTransport.</p></li>
  1599. <li><p>If a socket doesn&rsquo;t have backgrounding enabled, and that socket is closed while the app is backgrounded,<br/>
  1600. Apple only bothers to notify us via the CFStream API.<br/>
  1601. The faster and more powerful GCD API isn&rsquo;t notified properly in this case.</p></li>
  1602. </ul>
  1603. <p>See also: (BOOL)<a href="#//api/name/enableBackgroundingOnSocket">enableBackgroundingOnSocket</a></p>
  1604. </div>
  1605. <div class="method-subsection declared-in-section">
  1606. <h4 class="method-subtitle">Declared In</h4>
  1607. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1608. </div>
  1609. </div>
  1610. <div class="section-method">
  1611. <a name="//api/name/setAutoDisconnectOnClosedReadStream:" title="setAutoDisconnectOnClosedReadStream:"></a>
  1612. <h3 class="subsubtitle method-title">setAutoDisconnectOnClosedReadStream:</h3>
  1613. <div class="method-subsection method-declaration"><code>- (void)setAutoDisconnectOnClosedReadStream:(BOOL)<em>flag</em></code></div>
  1614. </div>
  1615. <div class="section-method">
  1616. <a name="//api/name/setDelegate:" title="setDelegate:"></a>
  1617. <h3 class="subsubtitle method-title">setDelegate:</h3>
  1618. <div class="method-subsection method-declaration"><code>- (void)setDelegate:(id)<em>delegate</em></code></div>
  1619. </div>
  1620. <div class="section-method">
  1621. <a name="//api/name/setDelegate:delegateQueue:" title="setDelegate:delegateQueue:"></a>
  1622. <h3 class="subsubtitle method-title">setDelegate:delegateQueue:</h3>
  1623. <div class="method-subsection method-declaration"><code>- (void)setDelegate:(id)<em>delegate</em> delegateQueue:(dispatch_queue_t)<em>delegateQueue</em></code></div>
  1624. </div>
  1625. <div class="section-method">
  1626. <a name="//api/name/setDelegateQueue:" title="setDelegateQueue:"></a>
  1627. <h3 class="subsubtitle method-title">setDelegateQueue:</h3>
  1628. <div class="method-subsection method-declaration"><code>- (void)setDelegateQueue:(dispatch_queue_t)<em>delegateQueue</em></code></div>
  1629. </div>
  1630. <div class="section-method">
  1631. <a name="//api/name/setIPv4Enabled:" title="setIPv4Enabled:"></a>
  1632. <h3 class="subsubtitle method-title">setIPv4Enabled:</h3>
  1633. <div class="method-subsection method-declaration"><code>- (void)setIPv4Enabled:(BOOL)<em>flag</em></code></div>
  1634. </div>
  1635. <div class="section-method">
  1636. <a name="//api/name/setIPv6Enabled:" title="setIPv6Enabled:"></a>
  1637. <h3 class="subsubtitle method-title">setIPv6Enabled:</h3>
  1638. <div class="method-subsection method-declaration"><code>- (void)setIPv6Enabled:(BOOL)<em>flag</em></code></div>
  1639. </div>
  1640. <div class="section-method">
  1641. <a name="//api/name/setPreferIPv4OverIPv6:" title="setPreferIPv4OverIPv6:"></a>
  1642. <h3 class="subsubtitle method-title">setPreferIPv4OverIPv6:</h3>
  1643. <div class="method-subsection method-declaration"><code>- (void)setPreferIPv4OverIPv6:(BOOL)<em>flag</em></code></div>
  1644. </div>
  1645. <div class="section-method">
  1646. <a name="//api/name/setUserData:" title="setUserData:"></a>
  1647. <h3 class="subsubtitle method-title">setUserData:</h3>
  1648. <div class="method-subsection method-declaration"><code>- (void)setUserData:(id)<em>arbitraryUserData</em></code></div>
  1649. </div>
  1650. <div class="section-method">
  1651. <a name="//api/name/socket4FD" title="socket4FD"></a>
  1652. <h3 class="subsubtitle method-title">socket4FD</h3>
  1653. <div class="method-subsection method-declaration"><code>- (int)socket4FD</code></div>
  1654. </div>
  1655. <div class="section-method">
  1656. <a name="//api/name/socket6FD" title="socket6FD"></a>
  1657. <h3 class="subsubtitle method-title">socket6FD</h3>
  1658. <div class="method-subsection method-declaration"><code>- (int)socket6FD</code></div>
  1659. </div>
  1660. <div class="section-method">
  1661. <a name="//api/name/socketFD" title="socketFD"></a>
  1662. <h3 class="subsubtitle method-title">socketFD</h3>
  1663. <div class="method-subsection brief-description">
  1664. <p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1665. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1666. </div>
  1667. <div class="method-subsection method-declaration"><code>- (int)socketFD</code></div>
  1668. <div class="method-subsection discussion-section">
  1669. <h4 class="method-subtitle">Discussion</h4>
  1670. <p>These methods are only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1671. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1672. <p>Provides access to the socket&rsquo;s file descriptor(s).<br/>
  1673. If the socket is a server socket (is accepting incoming connections),<br/>
  1674. it might actually have multiple internal socket file descriptors - one for IPv4 and one for IPv6.</p>
  1675. </div>
  1676. <div class="method-subsection declared-in-section">
  1677. <h4 class="method-subtitle">Declared In</h4>
  1678. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1679. </div>
  1680. </div>
  1681. <div class="section-method">
  1682. <a name="//api/name/sslContext" title="sslContext"></a>
  1683. <h3 class="subsubtitle method-title">sslContext</h3>
  1684. <div class="method-subsection brief-description">
  1685. <p>This method is only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1686. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1687. </div>
  1688. <div class="method-subsection method-declaration"><code>- (SSLContextRef)sslContext</code></div>
  1689. <div class="method-subsection discussion-section">
  1690. <h4 class="method-subtitle">Discussion</h4>
  1691. <p>This method is only available from within the context of a <a href="#//api/name/performBlock:">performBlock:</a> invocation.<br/>
  1692. See the documentation for the <a href="#//api/name/performBlock:">performBlock:</a> method above.</p>
  1693. <p>Provides access to the socket&rsquo;s SSLContext, if SSL/TLS has been started on the socket.</p>
  1694. </div>
  1695. <div class="method-subsection declared-in-section">
  1696. <h4 class="method-subtitle">Declared In</h4>
  1697. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1698. </div>
  1699. </div>
  1700. <div class="section-method">
  1701. <a name="//api/name/startTLS:" title="startTLS:"></a>
  1702. <h3 class="subsubtitle method-title">startTLS:</h3>
  1703. <div class="method-subsection brief-description">
  1704. <p>Secures the connection using SSL/TLS.</p>
  1705. </div>
  1706. <div class="method-subsection method-declaration"><code>- (void)startTLS:(NSDictionary *)<em>tlsSettings</em></code></div>
  1707. <div class="method-subsection discussion-section">
  1708. <h4 class="method-subtitle">Discussion</h4>
  1709. <p>Secures the connection using SSL/TLS.</p>
  1710. <p>This method may be called at any time, and the TLS handshake will occur after all pending reads and writes<br/>
  1711. are finished. This allows one the option of sending a protocol dependent StartTLS message, and queuing<br/>
  1712. the upgrade to TLS at the same time, without having to wait for the write to finish.<br/>
  1713. Any reads or writes scheduled after this method is called will occur over the secured connection.</p>
  1714. <p>The possible keys and values for the TLS settings are well documented.<br/>
  1715. Standard keys are:</p>
  1716. <ul>
  1717. <li>kCFStreamSSLLevel</li>
  1718. <li>kCFStreamSSLAllowsExpiredCertificates</li>
  1719. <li>kCFStreamSSLAllowsExpiredRoots</li>
  1720. <li>kCFStreamSSLAllowsAnyRoot</li>
  1721. <li>kCFStreamSSLValidatesCertificateChain</li>
  1722. <li>kCFStreamSSLPeerName</li>
  1723. <li>kCFStreamSSLCertificates</li>
  1724. <li>kCFStreamSSLIsServer</li>
  1725. </ul>
  1726. <p>If SecureTransport is available on iOS:</p>
  1727. <ul>
  1728. <li>GCDAsyncSocketSSLCipherSuites</li>
  1729. <li>GCDAsyncSocketSSLProtocolVersionMin</li>
  1730. <li>GCDAsyncSocketSSLProtocolVersionMax</li>
  1731. </ul>
  1732. <p>If SecureTransport is available on Mac OS X:</p>
  1733. <ul>
  1734. <li>GCDAsyncSocketSSLCipherSuites</li>
  1735. <li>GCDAsyncSocketSSLDiffieHellmanParameters;</li>
  1736. </ul>
  1737. <p>Please refer to Apple&rsquo;s documentation for associated values, as well as other possible keys.</p>
  1738. <p>If you pass in nil or an empty dictionary, the default settings will be used.</p>
  1739. <p>The default settings will check to make sure the remote party&rsquo;s certificate is signed by a<br/>
  1740. trusted 3rd party certificate agency (e.g. verisign) and that the certificate is not expired.<br/>
  1741. However it will not verify the name on the certificate unless you<br/>
  1742. give it a name to verify against via the kCFStreamSSLPeerName key.<br/>
  1743. The security implications of this are important to understand.<br/>
  1744. Imagine you are attempting to create a secure connection to MySecureServer.com,<br/>
  1745. but your socket gets directed to MaliciousServer.com because of a hacked DNS server.<br/>
  1746. If you simply use the default settings, and MaliciousServer.com has a valid certificate,<br/>
  1747. the default settings will not detect any problems since the certificate is valid.<br/>
  1748. To properly secure your connection in this particular scenario you<br/>
  1749. should set the kCFStreamSSLPeerName property to &ldquo;MySecureServer.com&rdquo;.<br/>
  1750. If you do not know the peer name of the remote host in advance (for example, you&rsquo;re not sure<br/>
  1751. if it will be &ldquo;domain.com&rdquo; or &ldquo;www.domain.com&rdquo;), then you can use the default settings to validate the<br/>
  1752. certificate, and then use the X509Certificate class to verify the issuer after the socket has been secured.<br/>
  1753. The X509Certificate class is part of the Cocoa<a href="../Classes/AsyncSocket.html">AsyncSocket</a> open source project.</p>
  1754. </div>
  1755. <div class="method-subsection declared-in-section">
  1756. <h4 class="method-subtitle">Declared In</h4>
  1757. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1758. </div>
  1759. </div>
  1760. <div class="section-method">
  1761. <a name="//api/name/synchronouslySetDelegate:" title="synchronouslySetDelegate:"></a>
  1762. <h3 class="subsubtitle method-title">synchronouslySetDelegate:</h3>
  1763. <div class="method-subsection method-declaration"><code>- (void)synchronouslySetDelegate:(id)<em>delegate</em></code></div>
  1764. </div>
  1765. <div class="section-method">
  1766. <a name="//api/name/synchronouslySetDelegate:delegateQueue:" title="synchronouslySetDelegate:delegateQueue:"></a>
  1767. <h3 class="subsubtitle method-title">synchronouslySetDelegate:delegateQueue:</h3>
  1768. <div class="method-subsection method-declaration"><code>- (void)synchronouslySetDelegate:(id)<em>delegate</em> delegateQueue:(dispatch_queue_t)<em>delegateQueue</em></code></div>
  1769. </div>
  1770. <div class="section-method">
  1771. <a name="//api/name/synchronouslySetDelegateQueue:" title="synchronouslySetDelegateQueue:"></a>
  1772. <h3 class="subsubtitle method-title">synchronouslySetDelegateQueue:</h3>
  1773. <div class="method-subsection method-declaration"><code>- (void)synchronouslySetDelegateQueue:(dispatch_queue_t)<em>delegateQueue</em></code></div>
  1774. </div>
  1775. <div class="section-method">
  1776. <a name="//api/name/userData" title="userData"></a>
  1777. <h3 class="subsubtitle method-title">userData</h3>
  1778. <div class="method-subsection brief-description">
  1779. <p>User data allows you to associate arbitrary information with the socket.<br/>
  1780. This data is not used internally by socket in any way.</p>
  1781. </div>
  1782. <div class="method-subsection method-declaration"><code>- (id)userData</code></div>
  1783. <div class="method-subsection discussion-section">
  1784. <h4 class="method-subtitle">Discussion</h4>
  1785. <p>User data allows you to associate arbitrary information with the socket.<br/>
  1786. This data is not used internally by socket in any way.</p>
  1787. </div>
  1788. <div class="method-subsection declared-in-section">
  1789. <h4 class="method-subtitle">Declared In</h4>
  1790. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1791. </div>
  1792. </div>
  1793. <div class="section-method">
  1794. <a name="//api/name/writeData:withTimeout:tag:" title="writeData:withTimeout:tag:"></a>
  1795. <h3 class="subsubtitle method-title">writeData:withTimeout:tag:</h3>
  1796. <div class="method-subsection brief-description">
  1797. <p>Writes data to the socket, and calls the <a href="#//api/name/delegate">delegate</a> when finished.</p>
  1798. </div>
  1799. <div class="method-subsection method-declaration"><code>- (void)writeData:(NSData *)<em>data</em> withTimeout:(NSTimeInterval)<em>timeout</em> tag:(long)<em>tag</em></code></div>
  1800. <div class="method-subsection discussion-section">
  1801. <h4 class="method-subtitle">Discussion</h4>
  1802. <p>Writes data to the socket, and calls the <a href="#//api/name/delegate">delegate</a> when finished.</p>
  1803. <p>If you pass in nil or zero-length data, this method does nothing and the <a href="#//api/name/delegate">delegate</a> will not be called.<br/>
  1804. If the timeout value is negative, the write operation will not use a timeout.</p>
  1805. <p>Thread-Safety Note:<br/>
  1806. If the given data parameter is mutable (NSMutableData) then you MUST NOT alter the data while<br/>
  1807. the socket is writing 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/>
  1808. socket:didWriteDataWithTag: is invoked signifying that this particular write operation has completed.<br/>
  1809. This is due to the fact that GCD<a href="../Classes/AsyncSocket.html">AsyncSocket</a> does NOT copy the data. It simply retains it.<br/>
  1810. This is for performance reasons. Often times, if NSMutableData is passed, it is because<br/>
  1811. a request/response was built up in memory. Copying this data adds an unwanted/unneeded overhead.<br/>
  1812. If you need to write data from an immutable buffer, and you need to alter the buffer before the socket<br/>
  1813. completes writing the bytes (which is NOT immediately after this method returns, but rather at a later time<br/>
  1814. 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>
  1815. </div>
  1816. <div class="method-subsection declared-in-section">
  1817. <h4 class="method-subtitle">Declared In</h4>
  1818. <code class="declared-in-ref">GCDAsyncSocket.h</code><br />
  1819. </div>
  1820. </div>
  1821. <div class="section-method">
  1822. <a name="//api/name/writeStream" title="writeStream"></a>
  1823. <h3 class="subsubtitle method-title">writeStream</h3>
  1824. <div class="method-subsection method-declaration"><code>- (CFWriteStreamRef)writeStream</code></div>
  1825. </div>
  1826. </div>
  1827. </div>
  1828. <div class="main-navigation navigation-bottom">
  1829. <ul>
  1830. <li><a href="../index.html">Index</a></li>
  1831. <li><a href="../hierarchy.html">Hierarchy</a></li>
  1832. </ul>
  1833. </div>
  1834. <div id="footer">
  1835. <hr />
  1836. <div class="footer-copyright">
  1837. <p><span class="copyright">&copy; 2013 Dustin Voss and Robbie Hanson. All rights reserved. (Last updated: 2013-04-24)</span><br />
  1838. <span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.1 (build 858)</a>.</span></p>
  1839. </div>
  1840. </div>
  1841. </div>
  1842. </article>
  1843. <script type="text/javascript">
  1844. function jumpToChange()
  1845. {
  1846. window.location.hash = this.options[this.selectedIndex].value;
  1847. }
  1848. function toggleTOC()
  1849. {
  1850. var contents = document.getElementById('contents');
  1851. var tocContainer = document.getElementById('tocContainer');
  1852. if (this.getAttribute('class') == 'open')
  1853. {
  1854. this.setAttribute('class', '');
  1855. contents.setAttribute('class', '');
  1856. tocContainer.setAttribute('class', '');
  1857. window.name = "hideTOC";
  1858. }
  1859. else
  1860. {
  1861. this.setAttribute('class', 'open');
  1862. contents.setAttribute('class', 'isShowingTOC');
  1863. tocContainer.setAttribute('class', 'isShowingTOC');
  1864. window.name = "";
  1865. }
  1866. return false;
  1867. }
  1868. function toggleTOCEntryChildren(e)
  1869. {
  1870. e.stopPropagation();
  1871. var currentClass = this.getAttribute('class');
  1872. if (currentClass == 'children') {
  1873. this.setAttribute('class', 'children open');
  1874. }
  1875. else if (currentClass == 'children open') {
  1876. this.setAttribute('class', 'children');
  1877. }
  1878. return false;
  1879. }
  1880. function tocEntryClick(e)
  1881. {
  1882. e.stopPropagation();
  1883. return true;
  1884. }
  1885. function init()
  1886. {
  1887. var selectElement = document.getElementById('jumpTo');
  1888. selectElement.addEventListener('change', jumpToChange, false);
  1889. var tocButton = document.getElementById('table_of_contents');
  1890. tocButton.addEventListener('click', toggleTOC, false);
  1891. var taskTreeItem = document.getElementById('task_treeitem');
  1892. if (taskTreeItem.getElementsByTagName('li').length > 0)
  1893. {
  1894. taskTreeItem.setAttribute('class', 'children');
  1895. taskTreeItem.firstChild.setAttribute('class', 'disclosure');
  1896. }
  1897. var tocList = document.getElementById('toc');
  1898. var tocEntries = tocList.getElementsByTagName('li');
  1899. for (var i = 0; i < tocEntries.length; i++) {
  1900. tocEntries[i].addEventListener('click', toggleTOCEntryChildren, false);
  1901. }
  1902. var tocLinks = tocList.getElementsByTagName('a');
  1903. for (var i = 0; i < tocLinks.length; i++) {
  1904. tocLinks[i].addEventListener('click', tocEntryClick, false);
  1905. }
  1906. if (window.name == "hideTOC") {
  1907. toggleTOC.call(tocButton);
  1908. }
  1909. }
  1910. window.onload = init;
  1911. // If showing in Xcode, hide the TOC and Header
  1912. if (navigator.userAgent.match(/xcode/i)) {
  1913. document.getElementById("contents").className = "hideInXcode"
  1914. document.getElementById("tocContainer").className = "hideInXcode"
  1915. document.getElementById("top_header").className = "hideInXcode"
  1916. }
  1917. </script>
  1918. </body>
  1919. </html>