PageRenderTime 84ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://gitlab.com/mba811/tokaidoapp
HTML | 2723 lines | 1419 code | 1304 blank | 0 comment | 0 complexity | 521388357f202c0aa2f3639ba34346b2 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>AsyncSocket 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">AsyncSocket 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="instance_methods">Instance Methods</option>
  34. <option value="//api/name/acceptOnInterface:port:error:">&nbsp;&nbsp;&nbsp;&nbsp;- acceptOnInterface:port:error:</option>
  35. <option value="//api/name/acceptOnPort:error:">&nbsp;&nbsp;&nbsp;&nbsp;- acceptOnPort:error:</option>
  36. <option value="//api/name/addRunLoopMode:">&nbsp;&nbsp;&nbsp;&nbsp;- addRunLoopMode:</option>
  37. <option value="//api/name/canSafelySetDelegate">&nbsp;&nbsp;&nbsp;&nbsp;- canSafelySetDelegate</option>
  38. <option value="//api/name/connectToAddress:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToAddress:error:</option>
  39. <option value="//api/name/connectToAddress:viaInterfaceAddress:withTimeout:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToAddress:viaInterfaceAddress:withTimeout:error:</option>
  40. <option value="//api/name/connectToAddress:withTimeout:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToAddress:withTimeout:error:</option>
  41. <option value="//api/name/connectToHost:onPort:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToHost:onPort:error:</option>
  42. <option value="//api/name/connectToHost:onPort:withTimeout:error:">&nbsp;&nbsp;&nbsp;&nbsp;- connectToHost:onPort:withTimeout:error:</option>
  43. <option value="//api/name/connectedAddress">&nbsp;&nbsp;&nbsp;&nbsp;- connectedAddress</option>
  44. <option value="//api/name/connectedHost">&nbsp;&nbsp;&nbsp;&nbsp;- connectedHost</option>
  45. <option value="//api/name/connectedPort">&nbsp;&nbsp;&nbsp;&nbsp;- connectedPort</option>
  46. <option value="//api/name/delegate">&nbsp;&nbsp;&nbsp;&nbsp;- delegate</option>
  47. <option value="//api/name/description">&nbsp;&nbsp;&nbsp;&nbsp;- description</option>
  48. <option value="//api/name/disconnect">&nbsp;&nbsp;&nbsp;&nbsp;- disconnect</option>
  49. <option value="//api/name/disconnectAfterReading">&nbsp;&nbsp;&nbsp;&nbsp;- disconnectAfterReading</option>
  50. <option value="//api/name/disconnectAfterReadingAndWriting">&nbsp;&nbsp;&nbsp;&nbsp;- disconnectAfterReadingAndWriting</option>
  51. <option value="//api/name/disconnectAfterWriting">&nbsp;&nbsp;&nbsp;&nbsp;- disconnectAfterWriting</option>
  52. <option value="//api/name/enablePreBuffering">&nbsp;&nbsp;&nbsp;&nbsp;- enablePreBuffering</option>
  53. <option value="//api/name/getCFReadStream">&nbsp;&nbsp;&nbsp;&nbsp;- getCFReadStream</option>
  54. <option value="//api/name/getCFSocket">&nbsp;&nbsp;&nbsp;&nbsp;- getCFSocket</option>
  55. <option value="//api/name/getCFWriteStream">&nbsp;&nbsp;&nbsp;&nbsp;- getCFWriteStream</option>
  56. <option value="//api/name/init">&nbsp;&nbsp;&nbsp;&nbsp;- init</option>
  57. <option value="//api/name/initWithDelegate:">&nbsp;&nbsp;&nbsp;&nbsp;- initWithDelegate:</option>
  58. <option value="//api/name/initWithDelegate:userData:">&nbsp;&nbsp;&nbsp;&nbsp;- initWithDelegate:userData:</option>
  59. <option value="//api/name/isConnected">&nbsp;&nbsp;&nbsp;&nbsp;- isConnected</option>
  60. <option value="//api/name/isIPv4">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv4</option>
  61. <option value="//api/name/isIPv6">&nbsp;&nbsp;&nbsp;&nbsp;- isIPv6</option>
  62. <option value="//api/name/localAddress">&nbsp;&nbsp;&nbsp;&nbsp;- localAddress</option>
  63. <option value="//api/name/localHost">&nbsp;&nbsp;&nbsp;&nbsp;- localHost</option>
  64. <option value="//api/name/localPort">&nbsp;&nbsp;&nbsp;&nbsp;- localPort</option>
  65. <option value="//api/name/moveToRunLoop:">&nbsp;&nbsp;&nbsp;&nbsp;- moveToRunLoop:</option>
  66. <option value="//api/name/progressOfReadReturningTag:bytesDone:total:">&nbsp;&nbsp;&nbsp;&nbsp;- progressOfReadReturningTag:bytesDone:total:</option>
  67. <option value="//api/name/progressOfWriteReturningTag:bytesDone:total:">&nbsp;&nbsp;&nbsp;&nbsp;- progressOfWriteReturningTag:bytesDone:total:</option>
  68. <option value="//api/name/readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:</option>
  69. <option value="//api/name/readDataToData:withTimeout:buffer:bufferOffset:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToData:withTimeout:buffer:bufferOffset:tag:</option>
  70. <option value="//api/name/readDataToData:withTimeout:maxLength:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToData:withTimeout:maxLength:tag:</option>
  71. <option value="//api/name/readDataToData:withTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToData:withTimeout:tag:</option>
  72. <option value="//api/name/readDataToLength:withTimeout:buffer:bufferOffset:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToLength:withTimeout:buffer:bufferOffset:tag:</option>
  73. <option value="//api/name/readDataToLength:withTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataToLength:withTimeout:tag:</option>
  74. <option value="//api/name/readDataWithTimeout:buffer:bufferOffset:maxLength:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataWithTimeout:buffer:bufferOffset:maxLength:tag:</option>
  75. <option value="//api/name/readDataWithTimeout:buffer:bufferOffset:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataWithTimeout:buffer:bufferOffset:tag:</option>
  76. <option value="//api/name/readDataWithTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- readDataWithTimeout:tag:</option>
  77. <option value="//api/name/removeRunLoopMode:">&nbsp;&nbsp;&nbsp;&nbsp;- removeRunLoopMode:</option>
  78. <option value="//api/name/runLoopModes">&nbsp;&nbsp;&nbsp;&nbsp;- runLoopModes</option>
  79. <option value="//api/name/setDelegate:">&nbsp;&nbsp;&nbsp;&nbsp;- setDelegate:</option>
  80. <option value="//api/name/setRunLoopModes:">&nbsp;&nbsp;&nbsp;&nbsp;- setRunLoopModes:</option>
  81. <option value="//api/name/setUserData:">&nbsp;&nbsp;&nbsp;&nbsp;- setUserData:</option>
  82. <option value="//api/name/startTLS:">&nbsp;&nbsp;&nbsp;&nbsp;- startTLS:</option>
  83. <option value="//api/name/unreadData">&nbsp;&nbsp;&nbsp;&nbsp;- unreadData</option>
  84. <option value="//api/name/userData">&nbsp;&nbsp;&nbsp;&nbsp;- userData</option>
  85. <option value="//api/name/writeData:withTimeout:tag:">&nbsp;&nbsp;&nbsp;&nbsp;- writeData:withTimeout:tag:</option>
  86. </select>
  87. </li>
  88. </ul>
  89. </header>
  90. <nav id="tocContainer" class="isShowingTOC">
  91. <ul id="toc" role="tree">
  92. <li role="treeitem" id="task_treeitem"><span class="nodisclosure"></span><span class="sectionName"><a href="#tasks">Tasks</a></span><ul>
  93. </ul></li>
  94. <li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#class_methods">Class Methods</a></span><ul>
  95. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/CRData">CRData</a></span></li>
  96. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/CRLFData">CRLFData</a></span></li>
  97. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/LFData">LFData</a></span></li>
  98. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/ZeroData">ZeroData</a></span></li>
  99. </ul></li>
  100. <li role="treeitem" class="children"><span class="disclosure"></span><span class="sectionName"><a href="#instance_methods">Instance Methods</a></span><ul>
  101. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/acceptOnInterface:port:error:">acceptOnInterface:port:error:</a></span></li>
  102. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a></span></li>
  103. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/addRunLoopMode:">addRunLoopMode:</a></span></li>
  104. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/canSafelySetDelegate">canSafelySetDelegate</a></span></li>
  105. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a></span></li>
  106. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToAddress:viaInterfaceAddress:withTimeout:error:">connectToAddress:viaInterfaceAddress:withTimeout:error:</a></span></li>
  107. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToAddress:withTimeout:error:">connectToAddress:withTimeout:error:</a></span></li>
  108. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a></span></li>
  109. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectToHost:onPort:withTimeout:error:">connectToHost:onPort:withTimeout:error:</a></span></li>
  110. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectedAddress">connectedAddress</a></span></li>
  111. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectedHost">connectedHost</a></span></li>
  112. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/connectedPort">connectedPort</a></span></li>
  113. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/delegate">delegate</a></span></li>
  114. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/description">description</a></span></li>
  115. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/disconnect">disconnect</a></span></li>
  116. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/disconnectAfterReading">disconnectAfterReading</a></span></li>
  117. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/disconnectAfterReadingAndWriting">disconnectAfterReadingAndWriting</a></span></li>
  118. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/disconnectAfterWriting">disconnectAfterWriting</a></span></li>
  119. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/enablePreBuffering">enablePreBuffering</a></span></li>
  120. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/getCFReadStream">getCFReadStream</a></span></li>
  121. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/getCFSocket">getCFSocket</a></span></li>
  122. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/getCFWriteStream">getCFWriteStream</a></span></li>
  123. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/init">init</a></span></li>
  124. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/initWithDelegate:">initWithDelegate:</a></span></li>
  125. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/initWithDelegate:userData:">initWithDelegate:userData:</a></span></li>
  126. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isConnected">isConnected</a></span></li>
  127. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv4">isIPv4</a></span></li>
  128. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/isIPv6">isIPv6</a></span></li>
  129. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localAddress">localAddress</a></span></li>
  130. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localHost">localHost</a></span></li>
  131. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/localPort">localPort</a></span></li>
  132. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/moveToRunLoop:">moveToRunLoop:</a></span></li>
  133. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/progressOfReadReturningTag:bytesDone:total:">progressOfReadReturningTag:bytesDone:total:</a></span></li>
  134. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/progressOfWriteReturningTag:bytesDone:total:">progressOfWriteReturningTag:bytesDone:total:</a></span></li>
  135. <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>
  136. <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>
  137. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataToData:withTimeout:maxLength:tag:">readDataToData:withTimeout:maxLength:tag:</a></span></li>
  138. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataToData:withTimeout:tag:">readDataToData:withTimeout:tag:</a></span></li>
  139. <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>
  140. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataToLength:withTimeout:tag:">readDataToLength:withTimeout:tag:</a></span></li>
  141. <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>
  142. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataWithTimeout:buffer:bufferOffset:tag:">readDataWithTimeout:buffer:bufferOffset:tag:</a></span></li>
  143. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/readDataWithTimeout:tag:">readDataWithTimeout:tag:</a></span></li>
  144. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/removeRunLoopMode:">removeRunLoopMode:</a></span></li>
  145. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/runLoopModes">runLoopModes</a></span></li>
  146. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setDelegate:">setDelegate:</a></span></li>
  147. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setRunLoopModes:">setRunLoopModes:</a></span></li>
  148. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/setUserData:">setUserData:</a></span></li>
  149. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/startTLS:">startTLS:</a></span></li>
  150. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/unreadData">unreadData</a></span></li>
  151. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/userData">userData</a></span></li>
  152. <li><span class="nodisclosure"></span><span class="sectionName"><a href="#//api/name/writeData:withTimeout:tag:">writeData:withTimeout:tag:</a></span></li>
  153. </ul></li>
  154. </ul>
  155. </nav>
  156. <article>
  157. <div id="contents" class="isShowingTOC" role="main">
  158. <a title="AsyncSocket Class Reference" name="top"></a>
  159. <div class="main-navigation navigation-top">
  160. <ul>
  161. <li><a href="../index.html">Index</a></li>
  162. <li><a href="../hierarchy.html">Hierarchy</a></li>
  163. </ul>
  164. </div>
  165. <div id="header">
  166. <div class="section-header">
  167. <h1 class="title title-header">AsyncSocket Class Reference</h1>
  168. </div>
  169. </div>
  170. <div id="container">
  171. <div class="section section-specification"><table cellspacing="0"><tbody>
  172. <tr>
  173. <td class="specification-title">Inherits from</td>
  174. <td class="specification-value">NSObject</td>
  175. </tr><tr>
  176. <td class="specification-title">Declared in</td>
  177. <td class="specification-value">AsyncSocket.h</td>
  178. </tr>
  179. </tbody></table></div>
  180. <div class="section section-tasks">
  181. <a title="Tasks" name="tasks"></a>
  182. <h2 class="subtitle subtitle-tasks">Tasks</h2>
  183. <ul class="task-list">
  184. <li>
  185. <span class="tooltip">
  186. <code><a href="#//api/name/init">&ndash;&nbsp;init</a></code>
  187. </span>
  188. </li><li>
  189. <span class="tooltip">
  190. <code><a href="#//api/name/initWithDelegate:">&ndash;&nbsp;initWithDelegate:</a></code>
  191. </span>
  192. </li><li>
  193. <span class="tooltip">
  194. <code><a href="#//api/name/initWithDelegate:userData:">&ndash;&nbsp;initWithDelegate:userData:</a></code>
  195. </span>
  196. </li><li>
  197. <span class="tooltip">
  198. <code><a href="#//api/name/description">&ndash;&nbsp;description</a></code>
  199. </span>
  200. </li><li>
  201. <span class="tooltip">
  202. <code><a href="#//api/name/delegate">&ndash;&nbsp;delegate</a></code>
  203. <span class="tooltip"><p>Use &ldquo;canSafelySetDelegate&rdquo; to see if there is any pending business (reads and writes) with the current delegate<br/>
  204. before changing it. It is, of course, safe to change the delegate before connecting or accepting connections.</p></span>
  205. </span>
  206. </li><li>
  207. <span class="tooltip">
  208. <code><a href="#//api/name/canSafelySetDelegate">&ndash;&nbsp;canSafelySetDelegate</a></code>
  209. </span>
  210. </li><li>
  211. <span class="tooltip">
  212. <code><a href="#//api/name/setDelegate:">&ndash;&nbsp;setDelegate:</a></code>
  213. </span>
  214. </li><li>
  215. <span class="tooltip">
  216. <code><a href="#//api/name/userData">&ndash;&nbsp;userData</a></code>
  217. </span>
  218. </li><li>
  219. <span class="tooltip">
  220. <code><a href="#//api/name/setUserData:">&ndash;&nbsp;setUserData:</a></code>
  221. </span>
  222. </li><li>
  223. <span class="tooltip">
  224. <code><a href="#//api/name/getCFSocket">&ndash;&nbsp;getCFSocket</a></code>
  225. </span>
  226. </li><li>
  227. <span class="tooltip">
  228. <code><a href="#//api/name/getCFReadStream">&ndash;&nbsp;getCFReadStream</a></code>
  229. </span>
  230. </li><li>
  231. <span class="tooltip">
  232. <code><a href="#//api/name/getCFWriteStream">&ndash;&nbsp;getCFWriteStream</a></code>
  233. </span>
  234. </li><li>
  235. <span class="tooltip">
  236. <code><a href="#//api/name/acceptOnPort:error:">&ndash;&nbsp;acceptOnPort:error:</a></code>
  237. <span class="tooltip"><p>Tells the socket to begin listening and accepting connections on the given port.<br/>
  238. When a connection comes in, the AsyncSocket instance will call the various <a href="#//api/name/delegate">delegate</a> methods (see above).<br/>
  239. The socket will listen on all available interfaces (e.g. wifi, ethernet, etc)</p></span>
  240. </span>
  241. </li><li>
  242. <span class="tooltip">
  243. <code><a href="#//api/name/acceptOnInterface:port:error:">&ndash;&nbsp;acceptOnInterface:port:error:</a></code>
  244. <span class="tooltip"><p>This method is the same as <a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a> with the additional option<br/>
  245. of specifying which interface to listen on. So, for example, if you were writing code for a server that<br/>
  246. has multiple IP addresses, you could specify which address you wanted to listen on. Or you could use it<br/>
  247. to specify that the socket should only accept connections over ethernet, and not other interfaces such as wifi.<br/>
  248. You may also use the special strings &ldquo;localhost&rdquo; or &ldquo;loopback&rdquo; to specify that<br/>
  249. the socket only accept connections from the local machine.</p></span>
  250. </span>
  251. </li><li>
  252. <span class="tooltip">
  253. <code><a href="#//api/name/connectToHost:onPort:error:">&ndash;&nbsp;connectToHost:onPort:error:</a></code>
  254. <span class="tooltip"><p>Connects to the given host and port.<br/>
  255. The host may be a domain name (e.g. &ldquo;deusty.com&rdquo;) or an IP address string (e.g. &ldquo;192.168.0.2&rdquo;)</p></span>
  256. </span>
  257. </li><li>
  258. <span class="tooltip">
  259. <code><a href="#//api/name/connectToHost:onPort:withTimeout:error:">&ndash;&nbsp;connectToHost:onPort:withTimeout:error:</a></code>
  260. <span class="tooltip"><p>This method is the same as <a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a> with an additional timeout option.<br/>
  261. To not time out use a negative time interval, or simply use the <a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a> method.</p></span>
  262. </span>
  263. </li><li>
  264. <span class="tooltip">
  265. <code><a href="#//api/name/connectToAddress:error:">&ndash;&nbsp;connectToAddress:error:</a></code>
  266. <span class="tooltip"><p>Connects to the given address, specified as a sockaddr structure wrapped in a NSData object.<br/>
  267. For example, a NSData object returned from NSNetService&rsquo;s addresses method.</p></span>
  268. </span>
  269. </li><li>
  270. <span class="tooltip">
  271. <code><a href="#//api/name/connectToAddress:withTimeout:error:">&ndash;&nbsp;connectToAddress:withTimeout:error:</a></code>
  272. <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/>
  273. 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>
  274. </span>
  275. </li><li>
  276. <span class="tooltip">
  277. <code><a href="#//api/name/connectToAddress:viaInterfaceAddress:withTimeout:error:">&ndash;&nbsp;connectToAddress:viaInterfaceAddress:withTimeout:error:</a></code>
  278. </span>
  279. </li><li>
  280. <span class="tooltip">
  281. <code><a href="#//api/name/disconnect">&ndash;&nbsp;disconnect</a></code>
  282. <span class="tooltip"><p>Disconnects immediately. Any pending reads or writes are dropped.<br/>
  283. If the socket is not already disconnected, the onSocketDidDisconnect <a href="#//api/name/delegate">delegate</a> method<br/>
  284. will be called immediately, before this method returns.</p></span>
  285. </span>
  286. </li><li>
  287. <span class="tooltip">
  288. <code><a href="#//api/name/disconnectAfterReading">&ndash;&nbsp;disconnectAfterReading</a></code>
  289. <span class="tooltip"><p>Disconnects after all pending reads have completed.<br/>
  290. After calling this, the read and write methods will do nothing.<br/>
  291. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending writes.</p></span>
  292. </span>
  293. </li><li>
  294. <span class="tooltip">
  295. <code><a href="#//api/name/disconnectAfterWriting">&ndash;&nbsp;disconnectAfterWriting</a></code>
  296. <span class="tooltip"><p>Disconnects after all pending writes have completed.<br/>
  297. After calling this, the read and write methods will do nothing.<br/>
  298. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending reads.</p></span>
  299. </span>
  300. </li><li>
  301. <span class="tooltip">
  302. <code><a href="#//api/name/disconnectAfterReadingAndWriting">&ndash;&nbsp;disconnectAfterReadingAndWriting</a></code>
  303. <span class="tooltip"><p>Disconnects after all pending reads and writes have completed.<br/>
  304. After calling this, the read and write methods will do nothing.</p></span>
  305. </span>
  306. </li><li>
  307. <span class="tooltip">
  308. <code><a href="#//api/name/isConnected">&ndash;&nbsp;isConnected</a></code>
  309. </span>
  310. </li><li>
  311. <span class="tooltip">
  312. <code><a href="#//api/name/connectedHost">&ndash;&nbsp;connectedHost</a></code>
  313. <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/>
  314. The host will be an IP address.</p></span>
  315. </span>
  316. </li><li>
  317. <span class="tooltip">
  318. <code><a href="#//api/name/connectedPort">&ndash;&nbsp;connectedPort</a></code>
  319. </span>
  320. </li><li>
  321. <span class="tooltip">
  322. <code><a href="#//api/name/localHost">&ndash;&nbsp;localHost</a></code>
  323. </span>
  324. </li><li>
  325. <span class="tooltip">
  326. <code><a href="#//api/name/localPort">&ndash;&nbsp;localPort</a></code>
  327. </span>
  328. </li><li>
  329. <span class="tooltip">
  330. <code><a href="#//api/name/connectedAddress">&ndash;&nbsp;connectedAddress</a></code>
  331. <span class="tooltip"><p>Returns the local or remote address to which this socket is connected,<br/>
  332. specified as a sockaddr structure wrapped in a NSData object.</p></span>
  333. </span>
  334. </li><li>
  335. <span class="tooltip">
  336. <code><a href="#//api/name/localAddress">&ndash;&nbsp;localAddress</a></code>
  337. </span>
  338. </li><li>
  339. <span class="tooltip">
  340. <code><a href="#//api/name/isIPv4">&ndash;&nbsp;isIPv4</a></code>
  341. <span class="tooltip"><p>Returns whether the socket is IPv4 or IPv6.<br/>
  342. An accepting socket may be both.</p></span>
  343. </span>
  344. </li><li>
  345. <span class="tooltip">
  346. <code><a href="#//api/name/isIPv6">&ndash;&nbsp;isIPv6</a></code>
  347. </span>
  348. </li><li>
  349. <span class="tooltip">
  350. <code><a href="#//api/name/readDataWithTimeout:tag:">&ndash;&nbsp;readDataWithTimeout:tag:</a></code>
  351. <span class="tooltip"><p>Reads the first available bytes that become available on the socket.</p></span>
  352. </span>
  353. </li><li>
  354. <span class="tooltip">
  355. <code><a href="#//api/name/readDataWithTimeout:buffer:bufferOffset:tag:">&ndash;&nbsp;readDataWithTimeout:buffer:bufferOffset:tag:</a></code>
  356. <span class="tooltip"><p>Reads the first available bytes that become available on the socket.<br/>
  357. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  358. The given buffer will automatically be increased in size if needed.</p></span>
  359. </span>
  360. </li><li>
  361. <span class="tooltip">
  362. <code><a href="#//api/name/readDataWithTimeout:buffer:bufferOffset:maxLength:tag:">&ndash;&nbsp;readDataWithTimeout:buffer:bufferOffset:maxLength:tag:</a></code>
  363. <span class="tooltip"><p>Reads the first available bytes that become available on the socket.<br/>
  364. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  365. The given buffer will automatically be increased in size if needed.<br/>
  366. A maximum of length bytes will be read.</p></span>
  367. </span>
  368. </li><li>
  369. <span class="tooltip">
  370. <code><a href="#//api/name/readDataToLength:withTimeout:tag:">&ndash;&nbsp;readDataToLength:withTimeout:tag:</a></code>
  371. <span class="tooltip"><p>Reads the given number of bytes.</p></span>
  372. </span>
  373. </li><li>
  374. <span class="tooltip">
  375. <code><a href="#//api/name/readDataToLength:withTimeout:buffer:bufferOffset:tag:">&ndash;&nbsp;readDataToLength:withTimeout:buffer:bufferOffset:tag:</a></code>
  376. <span class="tooltip"><p>Reads the given number of bytes.<br/>
  377. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  378. The given buffer will automatically be increased in size if needed.</p></span>
  379. </span>
  380. </li><li>
  381. <span class="tooltip">
  382. <code><a href="#//api/name/readDataToData:withTimeout:tag:">&ndash;&nbsp;readDataToData:withTimeout:tag:</a></code>
  383. <span class="tooltip"><p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p></span>
  384. </span>
  385. </li><li>
  386. <span class="tooltip">
  387. <code><a href="#//api/name/readDataToData:withTimeout:buffer:bufferOffset:tag:">&ndash;&nbsp;readDataToData:withTimeout:buffer:bufferOffset:tag:</a></code>
  388. <span class="tooltip"><p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  389. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  390. The given buffer will automatically be increased in size if needed.</p></span>
  391. </span>
  392. </li><li>
  393. <span class="tooltip">
  394. <code><a href="#//api/name/readDataToData:withTimeout:maxLength:tag:">&ndash;&nbsp;readDataToData:withTimeout:maxLength:tag:</a></code>
  395. <span class="tooltip"><p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p></span>
  396. </span>
  397. </li><li>
  398. <span class="tooltip">
  399. <code><a href="#//api/name/readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:">&ndash;&nbsp;readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:</a></code>
  400. <span class="tooltip"><p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  401. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  402. The given buffer will automatically be increased in size if needed.<br/>
  403. A maximum of length bytes will be read.</p></span>
  404. </span>
  405. </li><li>
  406. <span class="tooltip">
  407. <code><a href="#//api/name/writeData:withTimeout:tag:">&ndash;&nbsp;writeData:withTimeout:tag:</a></code>
  408. <span class="tooltip"><p>Writes data to the socket, and calls the <a href="#//api/name/delegate">delegate</a> when finished.</p></span>
  409. </span>
  410. </li><li>
  411. <span class="tooltip">
  412. <code><a href="#//api/name/progressOfReadReturningTag:bytesDone:total:">&ndash;&nbsp;progressOfReadReturningTag:bytesDone:total:</a></code>
  413. <span class="tooltip"><p>Returns progress of current read or write, from 0.0 to 1.0, or NaN if no read/write (use isnan() to check).<br/>
  414. &ldquo;tag&rdquo;, &ldquo;done&rdquo; and &ldquo;total&rdquo; will be filled in if they aren&rsquo;t NULL.</p></span>
  415. </span>
  416. </li><li>
  417. <span class="tooltip">
  418. <code><a href="#//api/name/progressOfWriteReturningTag:bytesDone:total:">&ndash;&nbsp;progressOfWriteReturningTag:bytesDone:total:</a></code>
  419. </span>
  420. </li><li>
  421. <span class="tooltip">
  422. <code><a href="#//api/name/startTLS:">&ndash;&nbsp;startTLS:</a></code>
  423. <span class="tooltip"><p>Secures the connection using SSL/TLS.</p></span>
  424. </span>
  425. </li><li>
  426. <span class="tooltip">
  427. <code><a href="#//api/name/enablePreBuffering">&ndash;&nbsp;enablePreBuffering</a></code>
  428. <span class="tooltip"><p>For handling readDataToData requests, data is necessarily read from the socket in small increments.<br/>
  429. The performance can be much improved by allowing AsyncSocket to read larger chunks at a time and<br/>
  430. store any overflow in a small internal buffer.<br/>
  431. This is termed pre-buffering, as some data may be read for you before you ask for it.<br/>
  432. If you use readDataToData a lot, enabling pre-buffering will result in better performance, especially on the iPhone.</p></span>
  433. </span>
  434. </li><li>
  435. <span class="tooltip">
  436. <code><a href="#//api/name/moveToRunLoop:">&ndash;&nbsp;moveToRunLoop:</a></code>
  437. <span class="tooltip"><p>When you create an AsyncSocket, it is added to the runloop of the current thread.<br/>
  438. So for manually created sockets, it is easiest to simply create the socket on the thread you intend to use it.</p></span>
  439. </span>
  440. </li><li>
  441. <span class="tooltip">
  442. <code><a href="#//api/name/setRunLoopModes:">&ndash;&nbsp;setRunLoopModes:</a></code>
  443. <span class="tooltip"><p>Allows you to configure which run loop modes the socket uses.<br/>
  444. The default set of run loop modes is NSDefaultRunLoopMode.</p></span>
  445. </span>
  446. </li><li>
  447. <span class="tooltip">
  448. <code><a href="#//api/name/addRunLoopMode:">&ndash;&nbsp;addRunLoopMode:</a></code>
  449. </span>
  450. </li><li>
  451. <span class="tooltip">
  452. <code><a href="#//api/name/removeRunLoopMode:">&ndash;&nbsp;removeRunLoopMode:</a></code>
  453. </span>
  454. </li><li>
  455. <span class="tooltip">
  456. <code><a href="#//api/name/runLoopModes">&ndash;&nbsp;runLoopModes</a></code>
  457. <span class="tooltip"><p>Returns the current run loop modes the AsyncSocket instance is operating in.<br/>
  458. The default set of run loop modes is NSDefaultRunLoopMode.</p></span>
  459. </span>
  460. </li><li>
  461. <span class="tooltip">
  462. <code><a href="#//api/name/unreadData">&ndash;&nbsp;unreadData</a></code>
  463. <span class="tooltip"><p>In the event of an error, this method may be called during onSocket:willDisconnectWithError: to read<br/>
  464. any data that&rsquo;s left on the socket.</p></span>
  465. </span>
  466. </li><li>
  467. <span class="tooltip">
  468. <code><a href="#//api/name/CRLFData">+&nbsp;CRLFData</a></code>
  469. </span>
  470. </li><li>
  471. <span class="tooltip">
  472. <code><a href="#//api/name/CRData">+&nbsp;CRData</a></code>
  473. </span>
  474. </li><li>
  475. <span class="tooltip">
  476. <code><a href="#//api/name/LFData">+&nbsp;LFData</a></code>
  477. </span>
  478. </li><li>
  479. <span class="tooltip">
  480. <code><a href="#//api/name/ZeroData">+&nbsp;ZeroData</a></code>
  481. </span>
  482. </li>
  483. </ul>
  484. </div>
  485. <div class="section section-methods">
  486. <a title="Class Methods" name="class_methods"></a>
  487. <h2 class="subtitle subtitle-methods">Class Methods</h2>
  488. <div class="section-method">
  489. <a name="//api/name/CRData" title="CRData"></a>
  490. <h3 class="subsubtitle method-title">CRData</h3>
  491. <div class="method-subsection method-declaration"><code>+ (NSData *)CRData</code></div>
  492. </div>
  493. <div class="section-method">
  494. <a name="//api/name/CRLFData" title="CRLFData"></a>
  495. <h3 class="subsubtitle method-title">CRLFData</h3>
  496. <div class="method-subsection method-declaration"><code>+ (NSData *)CRLFData</code></div>
  497. </div>
  498. <div class="section-method">
  499. <a name="//api/name/LFData" title="LFData"></a>
  500. <h3 class="subsubtitle method-title">LFData</h3>
  501. <div class="method-subsection method-declaration"><code>+ (NSData *)LFData</code></div>
  502. </div>
  503. <div class="section-method">
  504. <a name="//api/name/ZeroData" title="ZeroData"></a>
  505. <h3 class="subsubtitle method-title">ZeroData</h3>
  506. <div class="method-subsection method-declaration"><code>+ (NSData *)ZeroData</code></div>
  507. </div>
  508. </div>
  509. <div class="section section-methods">
  510. <a title="Instance Methods" name="instance_methods"></a>
  511. <h2 class="subtitle subtitle-methods">Instance Methods</h2>
  512. <div class="section-method">
  513. <a name="//api/name/acceptOnInterface:port:error:" title="acceptOnInterface:port:error:"></a>
  514. <h3 class="subsubtitle method-title">acceptOnInterface:port:error:</h3>
  515. <div class="method-subsection brief-description">
  516. <p>This method is the same as <a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a> with the additional option<br/>
  517. of specifying which interface to listen on. So, for example, if you were writing code for a server that<br/>
  518. has multiple IP addresses, you could specify which address you wanted to listen on. Or you could use it<br/>
  519. to specify that the socket should only accept connections over ethernet, and not other interfaces such as wifi.<br/>
  520. You may also use the special strings &ldquo;localhost&rdquo; or &ldquo;loopback&rdquo; to specify that<br/>
  521. the socket only accept connections from the local machine.</p>
  522. </div>
  523. <div class="method-subsection method-declaration"><code>- (BOOL)acceptOnInterface:(NSString *)<em>interface</em> port:(UInt16)<em>port</em> error:(NSError **)<em>errPtr</em></code></div>
  524. <div class="method-subsection discussion-section">
  525. <h4 class="method-subtitle">Discussion</h4>
  526. <p>This method is the same as <a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a> with the additional option<br/>
  527. of specifying which interface to listen on. So, for example, if you were writing code for a server that<br/>
  528. has multiple IP addresses, you could specify which address you wanted to listen on. Or you could use it<br/>
  529. to specify that the socket should only accept connections over ethernet, and not other interfaces such as wifi.<br/>
  530. You may also use the special strings &ldquo;localhost&rdquo; or &ldquo;loopback&rdquo; to specify that<br/>
  531. the socket only accept connections from the local machine.</p>
  532. <p>To accept connections on any interface pass nil, or simply use the <a href="#//api/name/acceptOnPort:error:">acceptOnPort:error:</a> method.</p>
  533. </div>
  534. <div class="method-subsection declared-in-section">
  535. <h4 class="method-subtitle">Declared In</h4>
  536. <code class="declared-in-ref">AsyncSocket.h</code><br />
  537. </div>
  538. </div>
  539. <div class="section-method">
  540. <a name="//api/name/acceptOnPort:error:" title="acceptOnPort:error:"></a>
  541. <h3 class="subsubtitle method-title">acceptOnPort:error:</h3>
  542. <div class="method-subsection brief-description">
  543. <p>Tells the socket to begin listening and accepting connections on the given port.<br/>
  544. When a connection comes in, the AsyncSocket instance will call the various <a href="#//api/name/delegate">delegate</a> methods (see above).<br/>
  545. The socket will listen on all available interfaces (e.g. wifi, ethernet, etc)</p>
  546. </div>
  547. <div class="method-subsection method-declaration"><code>- (BOOL)acceptOnPort:(UInt16)<em>port</em> error:(NSError **)<em>errPtr</em></code></div>
  548. <div class="method-subsection discussion-section">
  549. <h4 class="method-subtitle">Discussion</h4>
  550. <p>Tells the socket to begin listening and accepting connections on the given port.<br/>
  551. When a connection comes in, the AsyncSocket instance will call the various <a href="#//api/name/delegate">delegate</a> methods (see above).<br/>
  552. The socket will listen on all available interfaces (e.g. wifi, ethernet, etc)</p>
  553. </div>
  554. <div class="method-subsection declared-in-section">
  555. <h4 class="method-subtitle">Declared In</h4>
  556. <code class="declared-in-ref">AsyncSocket.h</code><br />
  557. </div>
  558. </div>
  559. <div class="section-method">
  560. <a name="//api/name/addRunLoopMode:" title="addRunLoopMode:"></a>
  561. <h3 class="subsubtitle method-title">addRunLoopMode:</h3>
  562. <div class="method-subsection method-declaration"><code>- (BOOL)addRunLoopMode:(NSString *)<em>runLoopMode</em></code></div>
  563. </div>
  564. <div class="section-method">
  565. <a name="//api/name/canSafelySetDelegate" title="canSafelySetDelegate"></a>
  566. <h3 class="subsubtitle method-title">canSafelySetDelegate</h3>
  567. <div class="method-subsection method-declaration"><code>- (BOOL)canSafelySetDelegate</code></div>
  568. </div>
  569. <div class="section-method">
  570. <a name="//api/name/connectToAddress:error:" title="connectToAddress:error:"></a>
  571. <h3 class="subsubtitle method-title">connectToAddress:error:</h3>
  572. <div class="method-subsection brief-description">
  573. <p>Connects to the given address, specified as a sockaddr structure wrapped in a NSData object.<br/>
  574. For example, a NSData object returned from NSNetService&rsquo;s addresses method.</p>
  575. </div>
  576. <div class="method-subsection method-declaration"><code>- (BOOL)connectToAddress:(NSData *)<em>remoteAddr</em> error:(NSError **)<em>errPtr</em></code></div>
  577. <div class="method-subsection discussion-section">
  578. <h4 class="method-subtitle">Discussion</h4>
  579. <p>Connects to the given address, specified as a sockaddr structure wrapped in a NSData object.<br/>
  580. For example, a NSData object returned from NSNetService&rsquo;s addresses method.</p>
  581. <p>If you have an existing struct sockaddr you can convert it to a NSData object like so:<br/>
  582. struct sockaddr sa -> NSData <em>dsa = [NSData dataWithBytes:&amp;remoteAddr length:remoteAddr.sa_len];<br/>
  583. struct sockaddr </em>sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len];</p>
  584. </div>
  585. <div class="method-subsection declared-in-section">
  586. <h4 class="method-subtitle">Declared In</h4>
  587. <code class="declared-in-ref">AsyncSocket.h</code><br />
  588. </div>
  589. </div>
  590. <div class="section-method">
  591. <a name="//api/name/connectToAddress:viaInterfaceAddress:withTimeout:error:" title="connectToAddress:viaInterfaceAddress:withTimeout:error:"></a>
  592. <h3 class="subsubtitle method-title">connectToAddress:viaInterfaceAddress:withTimeout:error:</h3>
  593. <div class="method-subsection method-declaration"><code>- (BOOL)connectToAddress:(NSData *)<em>remoteAddr</em> viaInterfaceAddress:(NSData *)<em>interfaceAddr</em> withTimeout:(NSTimeInterval)<em>timeout</em> error:(NSError **)<em>errPtr</em></code></div>
  594. </div>
  595. <div class="section-method">
  596. <a name="//api/name/connectToAddress:withTimeout:error:" title="connectToAddress:withTimeout:error:"></a>
  597. <h3 class="subsubtitle method-title">connectToAddress:withTimeout:error:</h3>
  598. <div class="method-subsection brief-description">
  599. <p>This method is the same as <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> with an additional timeout option.<br/>
  600. To not time out use a negative time interval, or simply use the <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> method.</p>
  601. </div>
  602. <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>
  603. <div class="method-subsection discussion-section">
  604. <h4 class="method-subtitle">Discussion</h4>
  605. <p>This method is the same as <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> with an additional timeout option.<br/>
  606. To not time out use a negative time interval, or simply use the <a href="#//api/name/connectToAddress:error:">connectToAddress:error:</a> method.</p>
  607. </div>
  608. <div class="method-subsection declared-in-section">
  609. <h4 class="method-subtitle">Declared In</h4>
  610. <code class="declared-in-ref">AsyncSocket.h</code><br />
  611. </div>
  612. </div>
  613. <div class="section-method">
  614. <a name="//api/name/connectToHost:onPort:error:" title="connectToHost:onPort:error:"></a>
  615. <h3 class="subsubtitle method-title">connectToHost:onPort:error:</h3>
  616. <div class="method-subsection brief-description">
  617. <p>Connects to the given host and port.<br/>
  618. The host may be a domain name (e.g. &ldquo;deusty.com&rdquo;) or an IP address string (e.g. &ldquo;192.168.0.2&rdquo;)</p>
  619. </div>
  620. <div class="method-subsection method-declaration"><code>- (BOOL)connectToHost:(NSString *)<em>hostname</em> onPort:(UInt16)<em>port</em> error:(NSError **)<em>errPtr</em></code></div>
  621. <div class="method-subsection discussion-section">
  622. <h4 class="method-subtitle">Discussion</h4>
  623. <p>Connects to the given host and port.<br/>
  624. The host may be a domain name (e.g. &ldquo;deusty.com&rdquo;) or an IP address string (e.g. &ldquo;192.168.0.2&rdquo;)</p>
  625. </div>
  626. <div class="method-subsection declared-in-section">
  627. <h4 class="method-subtitle">Declared In</h4>
  628. <code class="declared-in-ref">AsyncSocket.h</code><br />
  629. </div>
  630. </div>
  631. <div class="section-method">
  632. <a name="//api/name/connectToHost:onPort:withTimeout:error:" title="connectToHost:onPort:withTimeout:error:"></a>
  633. <h3 class="subsubtitle method-title">connectToHost:onPort:withTimeout:error:</h3>
  634. <div class="method-subsection brief-description">
  635. <p>This method is the same as <a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a> with an additional timeout option.<br/>
  636. To not time out use a negative time interval, or simply use the <a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a> method.</p>
  637. </div>
  638. <div class="method-subsection method-declaration"><code>- (BOOL)connectToHost:(NSString *)<em>hostname</em> onPort:(UInt16)<em>port</em> withTimeout:(NSTimeInterval)<em>timeout</em> error:(NSError **)<em>errPtr</em></code></div>
  639. <div class="method-subsection discussion-section">
  640. <h4 class="method-subtitle">Discussion</h4>
  641. <p>This method is the same as <a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a> with an additional timeout option.<br/>
  642. To not time out use a negative time interval, or simply use the <a href="#//api/name/connectToHost:onPort:error:">connectToHost:onPort:error:</a> method.</p>
  643. </div>
  644. <div class="method-subsection declared-in-section">
  645. <h4 class="method-subtitle">Declared In</h4>
  646. <code class="declared-in-ref">AsyncSocket.h</code><br />
  647. </div>
  648. </div>
  649. <div class="section-method">
  650. <a name="//api/name/connectedAddress" title="connectedAddress"></a>
  651. <h3 class="subsubtitle method-title">connectedAddress</h3>
  652. <div class="method-subsection brief-description">
  653. <p>Returns the local or remote address to which this socket is connected,<br/>
  654. specified as a sockaddr structure wrapped in a NSData object.</p>
  655. </div>
  656. <div class="method-subsection method-declaration"><code>- (NSData *)connectedAddress</code></div>
  657. <div class="method-subsection discussion-section">
  658. <h4 class="method-subtitle">Discussion</h4>
  659. <p>Returns the local or remote address to which this socket is connected,<br/>
  660. specified as a sockaddr structure wrapped in a NSData object.</p>
  661. <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>
  662. </div>
  663. <div class="method-subsection declared-in-section">
  664. <h4 class="method-subtitle">Declared In</h4>
  665. <code class="declared-in-ref">AsyncSocket.h</code><br />
  666. </div>
  667. </div>
  668. <div class="section-method">
  669. <a name="//api/name/connectedHost" title="connectedHost"></a>
  670. <h3 class="subsubtitle method-title">connectedHost</h3>
  671. <div class="method-subsection brief-description">
  672. <p>Returns the local or remote host and port to which this socket is connected, or nil and 0 if not connected.<br/>
  673. The host will be an IP address.</p>
  674. </div>
  675. <div class="method-subsection method-declaration"><code>- (NSString *)connectedHost</code></div>
  676. <div class="method-subsection discussion-section">
  677. <h4 class="method-subtitle">Discussion</h4>
  678. <p>Returns the local or remote host and port to which this socket is connected, or nil and 0 if not connected.<br/>
  679. The host will be an IP address.</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">AsyncSocket.h</code><br />
  684. </div>
  685. </div>
  686. <div class="section-method">
  687. <a name="//api/name/connectedPort" title="connectedPort"></a>
  688. <h3 class="subsubtitle method-title">connectedPort</h3>
  689. <div class="method-subsection method-declaration"><code>- (UInt16)connectedPort</code></div>
  690. </div>
  691. <div class="section-method">
  692. <a name="//api/name/delegate" title="delegate"></a>
  693. <h3 class="subsubtitle method-title">delegate</h3>
  694. <div class="method-subsection brief-description">
  695. <p>Use &ldquo;canSafelySetDelegate&rdquo; to see if there is any pending business (reads and writes) with the current delegate<br/>
  696. before changing it. It is, of course, safe to change the delegate before connecting or accepting connections.</p>
  697. </div>
  698. <div class="method-subsection method-declaration"><code>- (id)delegate</code></div>
  699. <div class="method-subsection discussion-section">
  700. <h4 class="method-subtitle">Discussion</h4>
  701. <p>Use &ldquo;canSafelySetDelegate&rdquo; to see if there is any pending business (reads and writes) with the current delegate<br/>
  702. before changing it. It is, of course, safe to change the delegate before connecting or accepting connections.</p>
  703. </div>
  704. <div class="method-subsection declared-in-section">
  705. <h4 class="method-subtitle">Declared In</h4>
  706. <code class="declared-in-ref">AsyncSocket.h</code><br />
  707. </div>
  708. </div>
  709. <div class="section-method">
  710. <a name="//api/name/description" title="description"></a>
  711. <h3 class="subsubtitle method-title">description</h3>
  712. <div class="method-subsection method-declaration"><code>- (NSString *)description</code></div>
  713. </div>
  714. <div class="section-method">
  715. <a name="//api/name/disconnect" title="disconnect"></a>
  716. <h3 class="subsubtitle method-title">disconnect</h3>
  717. <div class="method-subsection brief-description">
  718. <p>Disconnects immediately. Any pending reads or writes are dropped.<br/>
  719. If the socket is not already disconnected, the onSocketDidDisconnect <a href="#//api/name/delegate">delegate</a> method<br/>
  720. will be called immediately, before this method returns.</p>
  721. </div>
  722. <div class="method-subsection method-declaration"><code>- (void)disconnect</code></div>
  723. <div class="method-subsection discussion-section">
  724. <h4 class="method-subtitle">Discussion</h4>
  725. <p>Disconnects immediately. Any pending reads or writes are dropped.<br/>
  726. If the socket is not already disconnected, the onSocketDidDisconnect delegate method<br/>
  727. will be called immediately, before this method returns.</p>
  728. <p>Please note the recommended way of releasing an AsyncSocket instance (e.g. in a dealloc method)<br/>
  729. [asyncSocket setDelegate:nil];<br/>
  730. [asyncSocket disconnect];<br/>
  731. [asyncSocket release];</p>
  732. </div>
  733. <div class="method-subsection declared-in-section">
  734. <h4 class="method-subtitle">Declared In</h4>
  735. <code class="declared-in-ref">AsyncSocket.h</code><br />
  736. </div>
  737. </div>
  738. <div class="section-method">
  739. <a name="//api/name/disconnectAfterReading" title="disconnectAfterReading"></a>
  740. <h3 class="subsubtitle method-title">disconnectAfterReading</h3>
  741. <div class="method-subsection brief-description">
  742. <p>Disconnects after all pending reads have completed.<br/>
  743. After calling this, the read and write methods will do nothing.<br/>
  744. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending writes.</p>
  745. </div>
  746. <div class="method-subsection method-declaration"><code>- (void)disconnectAfterReading</code></div>
  747. <div class="method-subsection discussion-section">
  748. <h4 class="method-subtitle">Discussion</h4>
  749. <p>Disconnects after all pending reads have completed.<br/>
  750. After calling this, the read and write methods will do nothing.<br/>
  751. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending writes.</p>
  752. </div>
  753. <div class="method-subsection declared-in-section">
  754. <h4 class="method-subtitle">Declared In</h4>
  755. <code class="declared-in-ref">AsyncSocket.h</code><br />
  756. </div>
  757. </div>
  758. <div class="section-method">
  759. <a name="//api/name/disconnectAfterReadingAndWriting" title="disconnectAfterReadingAndWriting"></a>
  760. <h3 class="subsubtitle method-title">disconnectAfterReadingAndWriting</h3>
  761. <div class="method-subsection brief-description">
  762. <p>Disconnects after all pending reads and writes have completed.<br/>
  763. After calling this, the read and write methods will do nothing.</p>
  764. </div>
  765. <div class="method-subsection method-declaration"><code>- (void)disconnectAfterReadingAndWriting</code></div>
  766. <div class="method-subsection discussion-section">
  767. <h4 class="method-subtitle">Discussion</h4>
  768. <p>Disconnects after all pending reads and writes have completed.<br/>
  769. After calling this, the read and write methods will do nothing.</p>
  770. </div>
  771. <div class="method-subsection declared-in-section">
  772. <h4 class="method-subtitle">Declared In</h4>
  773. <code class="declared-in-ref">AsyncSocket.h</code><br />
  774. </div>
  775. </div>
  776. <div class="section-method">
  777. <a name="//api/name/disconnectAfterWriting" title="disconnectAfterWriting"></a>
  778. <h3 class="subsubtitle method-title">disconnectAfterWriting</h3>
  779. <div class="method-subsection brief-description">
  780. <p>Disconnects after all pending writes have completed.<br/>
  781. After calling this, the read and write methods will do nothing.<br/>
  782. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending reads.</p>
  783. </div>
  784. <div class="method-subsection method-declaration"><code>- (void)disconnectAfterWriting</code></div>
  785. <div class="method-subsection discussion-section">
  786. <h4 class="method-subtitle">Discussion</h4>
  787. <p>Disconnects after all pending writes have completed.<br/>
  788. After calling this, the read and write methods will do nothing.<br/>
  789. The socket will <a href="#//api/name/disconnect">disconnect</a> even if there are still pending reads.</p>
  790. </div>
  791. <div class="method-subsection declared-in-section">
  792. <h4 class="method-subtitle">Declared In</h4>
  793. <code class="declared-in-ref">AsyncSocket.h</code><br />
  794. </div>
  795. </div>
  796. <div class="section-method">
  797. <a name="//api/name/enablePreBuffering" title="enablePreBuffering"></a>
  798. <h3 class="subsubtitle method-title">enablePreBuffering</h3>
  799. <div class="method-subsection brief-description">
  800. <p>For handling readDataToData requests, data is necessarily read from the socket in small increments.<br/>
  801. The performance can be much improved by allowing AsyncSocket to read larger chunks at a time and<br/>
  802. store any overflow in a small internal buffer.<br/>
  803. This is termed pre-buffering, as some data may be read for you before you ask for it.<br/>
  804. If you use readDataToData a lot, enabling pre-buffering will result in better performance, especially on the iPhone.</p>
  805. </div>
  806. <div class="method-subsection method-declaration"><code>- (void)enablePreBuffering</code></div>
  807. <div class="method-subsection discussion-section">
  808. <h4 class="method-subtitle">Discussion</h4>
  809. <p>For handling readDataToData requests, data is necessarily read from the socket in small increments.<br/>
  810. The performance can be much improved by allowing AsyncSocket to read larger chunks at a time and<br/>
  811. store any overflow in a small internal buffer.<br/>
  812. This is termed pre-buffering, as some data may be read for you before you ask for it.<br/>
  813. If you use readDataToData a lot, enabling pre-buffering will result in better performance, especially on the iPhone.</p>
  814. <p>The default pre-buffering state is controlled by the DEFAULT_PREBUFFERING definition.<br/>
  815. It is highly recommended one leave this set to YES.</p>
  816. <p>This method exists in case pre-buffering needs to be disabled by default for some unforeseen reason.<br/>
  817. In that case, this method exists to allow one to easily enable pre-buffering when ready.</p>
  818. </div>
  819. <div class="method-subsection declared-in-section">
  820. <h4 class="method-subtitle">Declared In</h4>
  821. <code class="declared-in-ref">AsyncSocket.h</code><br />
  822. </div>
  823. </div>
  824. <div class="section-method">
  825. <a name="//api/name/getCFReadStream" title="getCFReadStream"></a>
  826. <h3 class="subsubtitle method-title">getCFReadStream</h3>
  827. <div class="method-subsection method-declaration"><code>- (CFReadStreamRef)getCFReadStream</code></div>
  828. </div>
  829. <div class="section-method">
  830. <a name="//api/name/getCFSocket" title="getCFSocket"></a>
  831. <h3 class="subsubtitle method-title">getCFSocket</h3>
  832. <div class="method-subsection method-declaration"><code>- (CFSocketRef)getCFSocket</code></div>
  833. </div>
  834. <div class="section-method">
  835. <a name="//api/name/getCFWriteStream" title="getCFWriteStream"></a>
  836. <h3 class="subsubtitle method-title">getCFWriteStream</h3>
  837. <div class="method-subsection method-declaration"><code>- (CFWriteStreamRef)getCFWriteStream</code></div>
  838. </div>
  839. <div class="section-method">
  840. <a name="//api/name/init" title="init"></a>
  841. <h3 class="subsubtitle method-title">init</h3>
  842. <div class="method-subsection method-declaration"><code>- (id)init</code></div>
  843. </div>
  844. <div class="section-method">
  845. <a name="//api/name/initWithDelegate:" title="initWithDelegate:"></a>
  846. <h3 class="subsubtitle method-title">initWithDelegate:</h3>
  847. <div class="method-subsection method-declaration"><code>- (id)initWithDelegate:(id)<em>delegate</em></code></div>
  848. </div>
  849. <div class="section-method">
  850. <a name="//api/name/initWithDelegate:userData:" title="initWithDelegate:userData:"></a>
  851. <h3 class="subsubtitle method-title">initWithDelegate:userData:</h3>
  852. <div class="method-subsection method-declaration"><code>- (id)initWithDelegate:(id)<em>delegate</em> userData:(long)<em>userData</em></code></div>
  853. </div>
  854. <div class="section-method">
  855. <a name="//api/name/isConnected" title="isConnected"></a>
  856. <h3 class="subsubtitle method-title">isConnected</h3>
  857. <div class="method-subsection method-declaration"><code>- (BOOL)isConnected</code></div>
  858. </div>
  859. <div class="section-method">
  860. <a name="//api/name/isIPv4" title="isIPv4"></a>
  861. <h3 class="subsubtitle method-title">isIPv4</h3>
  862. <div class="method-subsection brief-description">
  863. <p>Returns whether the socket is IPv4 or IPv6.<br/>
  864. An accepting socket may be both.</p>
  865. </div>
  866. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv4</code></div>
  867. <div class="method-subsection discussion-section">
  868. <h4 class="method-subtitle">Discussion</h4>
  869. <p>Returns whether the socket is IPv4 or IPv6.<br/>
  870. An accepting socket may be both.</p>
  871. </div>
  872. <div class="method-subsection declared-in-section">
  873. <h4 class="method-subtitle">Declared In</h4>
  874. <code class="declared-in-ref">AsyncSocket.h</code><br />
  875. </div>
  876. </div>
  877. <div class="section-method">
  878. <a name="//api/name/isIPv6" title="isIPv6"></a>
  879. <h3 class="subsubtitle method-title">isIPv6</h3>
  880. <div class="method-subsection method-declaration"><code>- (BOOL)isIPv6</code></div>
  881. </div>
  882. <div class="section-method">
  883. <a name="//api/name/localAddress" title="localAddress"></a>
  884. <h3 class="subsubtitle method-title">localAddress</h3>
  885. <div class="method-subsection method-declaration"><code>- (NSData *)localAddress</code></div>
  886. </div>
  887. <div class="section-method">
  888. <a name="//api/name/localHost" title="localHost"></a>
  889. <h3 class="subsubtitle method-title">localHost</h3>
  890. <div class="method-subsection method-declaration"><code>- (NSString *)localHost</code></div>
  891. </div>
  892. <div class="section-method">
  893. <a name="//api/name/localPort" title="localPort"></a>
  894. <h3 class="subsubtitle method-title">localPort</h3>
  895. <div class="method-subsection method-declaration"><code>- (UInt16)localPort</code></div>
  896. </div>
  897. <div class="section-method">
  898. <a name="//api/name/moveToRunLoop:" title="moveToRunLoop:"></a>
  899. <h3 class="subsubtitle method-title">moveToRunLoop:</h3>
  900. <div class="method-subsection brief-description">
  901. <p>When you create an AsyncSocket, it is added to the runloop of the current thread.<br/>
  902. So for manually created sockets, it is easiest to simply create the socket on the thread you intend to use it.</p>
  903. </div>
  904. <div class="method-subsection method-declaration"><code>- (BOOL)moveToRunLoop:(NSRunLoop *)<em>runLoop</em></code></div>
  905. <div class="method-subsection discussion-section">
  906. <h4 class="method-subtitle">Discussion</h4>
  907. <p>When you create an AsyncSocket, it is added to the runloop of the current thread.<br/>
  908. So for manually created sockets, it is easiest to simply create the socket on the thread you intend to use it.</p>
  909. <p>If a new socket is accepted, the <a href="#//api/name/delegate">delegate</a> method onSocket:wantsRunLoopForNewSocket: is called to<br/>
  910. allow you to place the socket on a separate thread. This works best in conjunction with a thread pool design.</p>
  911. <p>If, however, you need to move the socket to a separate thread at a later time, this<br/>
  912. method may be used to accomplish the task.</p>
  913. <p>This method must be called from the thread/runloop the socket is currently running on.</p>
  914. <p>Note: After calling this method, all further method calls to this object should be done from the given runloop.<br/>
  915. Also, all <a href="#//api/name/delegate">delegate</a> calls will be sent on the given runloop.</p>
  916. </div>
  917. <div class="method-subsection declared-in-section">
  918. <h4 class="method-subtitle">Declared In</h4>
  919. <code class="declared-in-ref">AsyncSocket.h</code><br />
  920. </div>
  921. </div>
  922. <div class="section-method">
  923. <a name="//api/name/progressOfReadReturningTag:bytesDone:total:" title="progressOfReadReturningTag:bytesDone:total:"></a>
  924. <h3 class="subsubtitle method-title">progressOfReadReturningTag:bytesDone:total:</h3>
  925. <div class="method-subsection brief-description">
  926. <p>Returns progress of current read or write, from 0.0 to 1.0, or NaN if no read/write (use isnan() to check).<br/>
  927. &ldquo;tag&rdquo;, &ldquo;done&rdquo; and &ldquo;total&rdquo; will be filled in if they aren&rsquo;t NULL.</p>
  928. </div>
  929. <div class="method-subsection method-declaration"><code>- (float)progressOfReadReturningTag:(long *)<em>tag</em> bytesDone:(NSUInteger *)<em>done</em> total:(NSUInteger *)<em>total</em></code></div>
  930. <div class="method-subsection discussion-section">
  931. <h4 class="method-subtitle">Discussion</h4>
  932. <p>Returns progress of current read or write, from 0.0 to 1.0, or NaN if no read/write (use isnan() to check).<br/>
  933. &ldquo;tag&rdquo;, &ldquo;done&rdquo; and &ldquo;total&rdquo; will be filled in if they aren&rsquo;t NULL.</p>
  934. </div>
  935. <div class="method-subsection declared-in-section">
  936. <h4 class="method-subtitle">Declared In</h4>
  937. <code class="declared-in-ref">AsyncSocket.h</code><br />
  938. </div>
  939. </div>
  940. <div class="section-method">
  941. <a name="//api/name/progressOfWriteReturningTag:bytesDone:total:" title="progressOfWriteReturningTag:bytesDone:total:"></a>
  942. <h3 class="subsubtitle method-title">progressOfWriteReturningTag:bytesDone:total:</h3>
  943. <div class="method-subsection method-declaration"><code>- (float)progressOfWriteReturningTag:(long *)<em>tag</em> bytesDone:(NSUInteger *)<em>done</em> total:(NSUInteger *)<em>total</em></code></div>
  944. </div>
  945. <div class="section-method">
  946. <a name="//api/name/readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:" title="readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:"></a>
  947. <h3 class="subsubtitle method-title">readDataToData:withTimeout:buffer:bufferOffset:maxLength:tag:</h3>
  948. <div class="method-subsection brief-description">
  949. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  950. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  951. The given buffer will automatically be increased in size if needed.<br/>
  952. A maximum of length bytes will be read.</p>
  953. </div>
  954. <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>
  955. <div class="method-subsection discussion-section">
  956. <h4 class="method-subtitle">Discussion</h4>
  957. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  958. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  959. The given buffer will automatically be increased in size if needed.<br/>
  960. A maximum of length bytes will be read.</p>
  961. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  962. If the buffer if nil, a buffer will automatically be created for you.</p>
  963. <p>If maxLength is zero, no length restriction is enforced.<br/>
  964. Otherwise if maxLength bytes are read without completing the read,<br/>
  965. it is treated similarly to a timeout - the socket is closed with a AsyncSocketReadMaxedOutError.<br/>
  966. The read will complete successfully if exactly maxLength bytes are read and the given data is found at the end.</p>
  967. <p>If you pass a maxLength parameter that is less than the length of the data parameter,<br/>
  968. the method will do nothing, and the <a href="#//api/name/delegate">delegate</a> will not be called.<br/>
  969. If the bufferOffset is greater than the length of the given buffer,<br/>
  970. the method will do nothing, and the <a href="#//api/name/delegate">delegate</a> will not be called.</p>
  971. <p>If you pass a buffer, you must not alter it in any way while AsyncSocket is using it.<br/>
  972. After completion, the data returned in onSocket:didReadData:withTag: will be a subset of the given buffer.<br/>
  973. That is, it will reference the bytes that were appended to the given buffer.</p>
  974. <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/>
  975. Note that this method is not character-set aware, so if a separator can occur naturally as part of the encoding for<br/>
  976. a character, the read will prematurely end.</p>
  977. </div>
  978. <div class="method-subsection declared-in-section">
  979. <h4 class="method-subtitle">Declared In</h4>
  980. <code class="declared-in-ref">AsyncSocket.h</code><br />
  981. </div>
  982. </div>
  983. <div class="section-method">
  984. <a name="//api/name/readDataToData:withTimeout:buffer:bufferOffset:tag:" title="readDataToData:withTimeout:buffer:bufferOffset:tag:"></a>
  985. <h3 class="subsubtitle method-title">readDataToData:withTimeout:buffer:bufferOffset:tag:</h3>
  986. <div class="method-subsection brief-description">
  987. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  988. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  989. The given buffer will automatically be increased in size if needed.</p>
  990. </div>
  991. <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>
  992. <div class="method-subsection discussion-section">
  993. <h4 class="method-subtitle">Discussion</h4>
  994. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.<br/>
  995. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  996. The given buffer will automatically be increased in size if needed.</p>
  997. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  998. If the buffer if nil, a buffer will automatically be created for you.</p>
  999. <p>If the bufferOffset is greater than the length of the given buffer,<br/>
  1000. the method will do nothing, and the <a href="#//api/name/delegate">delegate</a> will not be called.</p>
  1001. <p>If you pass a buffer, you must not alter it in any way while AsyncSocket is using it.<br/>
  1002. After completion, the data returned in onSocket:didReadData:withTag: will be a subset of the given buffer.<br/>
  1003. That is, it will reference the bytes that were appended to the given buffer.</p>
  1004. <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/>
  1005. Note that this method is not character-set aware, so if a separator can occur naturally as part of the encoding for<br/>
  1006. a character, the read will prematurely end.</p>
  1007. </div>
  1008. <div class="method-subsection declared-in-section">
  1009. <h4 class="method-subtitle">Declared In</h4>
  1010. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1011. </div>
  1012. </div>
  1013. <div class="section-method">
  1014. <a name="//api/name/readDataToData:withTimeout:maxLength:tag:" title="readDataToData:withTimeout:maxLength:tag:"></a>
  1015. <h3 class="subsubtitle method-title">readDataToData:withTimeout:maxLength:tag:</h3>
  1016. <div class="method-subsection brief-description">
  1017. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p>
  1018. </div>
  1019. <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>
  1020. <div class="method-subsection discussion-section">
  1021. <h4 class="method-subtitle">Discussion</h4>
  1022. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p>
  1023. <p>If the timeout value is negative, the read operation will not use a timeout.</p>
  1024. <p>If maxLength is zero, no length restriction is enforced.<br/>
  1025. Otherwise if maxLength bytes are read without completing the read,<br/>
  1026. it is treated similarly to a timeout - the socket is closed with a AsyncSocketReadMaxedOutError.<br/>
  1027. The read will complete successfully if exactly maxLength bytes are read and the given data is found at the end.</p>
  1028. <p>If you pass nil or zero-length data as the &ldquo;data&rdquo; parameter,<br/>
  1029. the method will do nothing, and the <a href="#//api/name/delegate">delegate</a> will not be called.<br/>
  1030. If you pass a maxLength parameter that is less than the length of the data parameter,<br/>
  1031. the method will do nothing, and the <a href="#//api/name/delegate">delegate</a> will not be called.</p>
  1032. <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/>
  1033. Note that this method is not character-set aware, so if a separator can occur naturally as part of the encoding for<br/>
  1034. a character, the read will prematurely end.</p>
  1035. </div>
  1036. <div class="method-subsection declared-in-section">
  1037. <h4 class="method-subtitle">Declared In</h4>
  1038. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1039. </div>
  1040. </div>
  1041. <div class="section-method">
  1042. <a name="//api/name/readDataToData:withTimeout:tag:" title="readDataToData:withTimeout:tag:"></a>
  1043. <h3 class="subsubtitle method-title">readDataToData:withTimeout:tag:</h3>
  1044. <div class="method-subsection brief-description">
  1045. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p>
  1046. </div>
  1047. <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>
  1048. <div class="method-subsection discussion-section">
  1049. <h4 class="method-subtitle">Discussion</h4>
  1050. <p>Reads bytes until (and including) the passed &ldquo;data&rdquo; parameter, which acts as a separator.</p>
  1051. <p>If the timeout value is negative, the read operation will not use a timeout.</p>
  1052. <p>If you pass nil or zero-length data as the &ldquo;data&rdquo; parameter,<br/>
  1053. the method will do nothing, and the <a href="#//api/name/delegate">delegate</a> will not be called.</p>
  1054. <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/>
  1055. Note that this method is not character-set aware, so if a separator can occur naturally as part of the encoding for<br/>
  1056. a character, the read will prematurely end.</p>
  1057. </div>
  1058. <div class="method-subsection declared-in-section">
  1059. <h4 class="method-subtitle">Declared In</h4>
  1060. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1061. </div>
  1062. </div>
  1063. <div class="section-method">
  1064. <a name="//api/name/readDataToLength:withTimeout:buffer:bufferOffset:tag:" title="readDataToLength:withTimeout:buffer:bufferOffset:tag:"></a>
  1065. <h3 class="subsubtitle method-title">readDataToLength:withTimeout:buffer:bufferOffset:tag:</h3>
  1066. <div class="method-subsection brief-description">
  1067. <p>Reads the given number of bytes.<br/>
  1068. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1069. The given buffer will automatically be increased in size if needed.</p>
  1070. </div>
  1071. <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>
  1072. <div class="method-subsection discussion-section">
  1073. <h4 class="method-subtitle">Discussion</h4>
  1074. <p>Reads the given number of bytes.<br/>
  1075. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1076. The given buffer will automatically be increased in size if needed.</p>
  1077. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  1078. If the buffer if nil, a buffer will automatically be created for you.</p>
  1079. <p>If the length is 0, this method does nothing and the <a href="#//api/name/delegate">delegate</a> is not called.<br/>
  1080. If the bufferOffset is greater than the length of the given buffer,<br/>
  1081. the method will do nothing, and the <a href="#//api/name/delegate">delegate</a> will not be called.</p>
  1082. <p>If you pass a buffer, you must not alter it in any way while AsyncSocket is using it.<br/>
  1083. After completion, the data returned in onSocket:didReadData:withTag: will be a subset of the given buffer.<br/>
  1084. That is, it will reference the bytes that were appended to the given buffer.</p>
  1085. </div>
  1086. <div class="method-subsection declared-in-section">
  1087. <h4 class="method-subtitle">Declared In</h4>
  1088. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1089. </div>
  1090. </div>
  1091. <div class="section-method">
  1092. <a name="//api/name/readDataToLength:withTimeout:tag:" title="readDataToLength:withTimeout:tag:"></a>
  1093. <h3 class="subsubtitle method-title">readDataToLength:withTimeout:tag:</h3>
  1094. <div class="method-subsection brief-description">
  1095. <p>Reads the given number of bytes.</p>
  1096. </div>
  1097. <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>
  1098. <div class="method-subsection discussion-section">
  1099. <h4 class="method-subtitle">Discussion</h4>
  1100. <p>Reads the given number of bytes.</p>
  1101. <p>If the timeout value is negative, the read operation will not use a timeout.</p>
  1102. <p>If the length is 0, this method does nothing and the <a href="#//api/name/delegate">delegate</a> is not called.</p>
  1103. </div>
  1104. <div class="method-subsection declared-in-section">
  1105. <h4 class="method-subtitle">Declared In</h4>
  1106. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1107. </div>
  1108. </div>
  1109. <div class="section-method">
  1110. <a name="//api/name/readDataWithTimeout:buffer:bufferOffset:maxLength:tag:" title="readDataWithTimeout:buffer:bufferOffset:maxLength:tag:"></a>
  1111. <h3 class="subsubtitle method-title">readDataWithTimeout:buffer:bufferOffset:maxLength:tag:</h3>
  1112. <div class="method-subsection brief-description">
  1113. <p>Reads the first available bytes that become available on the socket.<br/>
  1114. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1115. The given buffer will automatically be increased in size if needed.<br/>
  1116. A maximum of length bytes will be read.</p>
  1117. </div>
  1118. <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>
  1119. <div class="method-subsection discussion-section">
  1120. <h4 class="method-subtitle">Discussion</h4>
  1121. <p>Reads the first available bytes that become available on the socket.<br/>
  1122. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1123. The given buffer will automatically be increased in size if needed.<br/>
  1124. A maximum of length bytes will be read.</p>
  1125. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  1126. If the buffer if nil, a buffer will automatically be created for you.<br/>
  1127. If maxLength is zero, no length restriction is enforced.</p>
  1128. <p>If the bufferOffset is greater than the length of the given buffer,<br/>
  1129. the method will do nothing, and the <a href="#//api/name/delegate">delegate</a> will not be called.</p>
  1130. <p>If you pass a buffer, you must not alter it in any way while AsyncSocket is using it.<br/>
  1131. After completion, the data returned in onSocket:didReadData:withTag: will be a subset of the given buffer.<br/>
  1132. That is, it will reference the bytes that were appended to the given buffer.</p>
  1133. </div>
  1134. <div class="method-subsection declared-in-section">
  1135. <h4 class="method-subtitle">Declared In</h4>
  1136. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1137. </div>
  1138. </div>
  1139. <div class="section-method">
  1140. <a name="//api/name/readDataWithTimeout:buffer:bufferOffset:tag:" title="readDataWithTimeout:buffer:bufferOffset:tag:"></a>
  1141. <h3 class="subsubtitle method-title">readDataWithTimeout:buffer:bufferOffset:tag:</h3>
  1142. <div class="method-subsection brief-description">
  1143. <p>Reads the first available bytes that become available on the socket.<br/>
  1144. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1145. The given buffer will automatically be increased in size if needed.</p>
  1146. </div>
  1147. <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>
  1148. <div class="method-subsection discussion-section">
  1149. <h4 class="method-subtitle">Discussion</h4>
  1150. <p>Reads the first available bytes that become available on the socket.<br/>
  1151. The bytes will be appended to the given byte buffer starting at the given offset.<br/>
  1152. The given buffer will automatically be increased in size if needed.</p>
  1153. <p>If the timeout value is negative, the read operation will not use a timeout.<br/>
  1154. If the buffer if nil, the socket will create a buffer for you.</p>
  1155. <p>If the bufferOffset is greater than the length of the given buffer,<br/>
  1156. the method will do nothing, and the <a href="#//api/name/delegate">delegate</a> will not be called.</p>
  1157. <p>If you pass a buffer, you must not alter it in any way while AsyncSocket is using it.<br/>
  1158. After completion, the data returned in onSocket:didReadData:withTag: will be a subset of the given buffer.<br/>
  1159. That is, it will reference the bytes that were appended to the given buffer.</p>
  1160. </div>
  1161. <div class="method-subsection declared-in-section">
  1162. <h4 class="method-subtitle">Declared In</h4>
  1163. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1164. </div>
  1165. </div>
  1166. <div class="section-method">
  1167. <a name="//api/name/readDataWithTimeout:tag:" title="readDataWithTimeout:tag:"></a>
  1168. <h3 class="subsubtitle method-title">readDataWithTimeout:tag:</h3>
  1169. <div class="method-subsection brief-description">
  1170. <p>Reads the first available bytes that become available on the socket.</p>
  1171. </div>
  1172. <div class="method-subsection method-declaration"><code>- (void)readDataWithTimeout:(NSTimeInterval)<em>timeout</em> tag:(long)<em>tag</em></code></div>
  1173. <div class="method-subsection discussion-section">
  1174. <h4 class="method-subtitle">Discussion</h4>
  1175. <p>Reads the first available bytes that become available on the socket.</p>
  1176. <p>If the timeout value is negative, the read operation will not use a timeout.</p>
  1177. </div>
  1178. <div class="method-subsection declared-in-section">
  1179. <h4 class="method-subtitle">Declared In</h4>
  1180. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1181. </div>
  1182. </div>
  1183. <div class="section-method">
  1184. <a name="//api/name/removeRunLoopMode:" title="removeRunLoopMode:"></a>
  1185. <h3 class="subsubtitle method-title">removeRunLoopMode:</h3>
  1186. <div class="method-subsection method-declaration"><code>- (BOOL)removeRunLoopMode:(NSString *)<em>runLoopMode</em></code></div>
  1187. </div>
  1188. <div class="section-method">
  1189. <a name="//api/name/runLoopModes" title="runLoopModes"></a>
  1190. <h3 class="subsubtitle method-title">runLoopModes</h3>
  1191. <div class="method-subsection brief-description">
  1192. <p>Returns the current run loop modes the AsyncSocket instance is operating in.<br/>
  1193. The default set of run loop modes is NSDefaultRunLoopMode.</p>
  1194. </div>
  1195. <div class="method-subsection method-declaration"><code>- (NSArray *)runLoopModes</code></div>
  1196. <div class="method-subsection discussion-section">
  1197. <h4 class="method-subtitle">Discussion</h4>
  1198. <p>Returns the current run loop modes the AsyncSocket instance is operating in.<br/>
  1199. The default set of run loop modes is NSDefaultRunLoopMode.</p>
  1200. </div>
  1201. <div class="method-subsection declared-in-section">
  1202. <h4 class="method-subtitle">Declared In</h4>
  1203. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1204. </div>
  1205. </div>
  1206. <div class="section-method">
  1207. <a name="//api/name/setDelegate:" title="setDelegate:"></a>
  1208. <h3 class="subsubtitle method-title">setDelegate:</h3>
  1209. <div class="method-subsection method-declaration"><code>- (void)setDelegate:(id)<em>delegate</em></code></div>
  1210. </div>
  1211. <div class="section-method">
  1212. <a name="//api/name/setRunLoopModes:" title="setRunLoopModes:"></a>
  1213. <h3 class="subsubtitle method-title">setRunLoopModes:</h3>
  1214. <div class="method-subsection brief-description">
  1215. <p>Allows you to configure which run loop modes the socket uses.<br/>
  1216. The default set of run loop modes is NSDefaultRunLoopMode.</p>
  1217. </div>
  1218. <div class="method-subsection method-declaration"><code>- (BOOL)setRunLoopModes:(NSArray *)<em>runLoopModes</em></code></div>
  1219. <div class="method-subsection discussion-section">
  1220. <h4 class="method-subtitle">Discussion</h4>
  1221. <p>Allows you to configure which run loop modes the socket uses.<br/>
  1222. The default set of run loop modes is NSDefaultRunLoopMode.</p>
  1223. <p>If you&rsquo;d like your socket to continue operation during other modes, you may want to add modes such as<br/>
  1224. NSModalPanelRunLoopMode or NSEventTrackingRunLoopMode. Or you may simply want to use NSRunLoopCommonModes.</p>
  1225. <p>Accepted sockets will automatically inherit the same run loop modes as the listening socket.</p>
  1226. <p>Note: NSRunLoopCommonModes is defined in 10.5. For previous versions one can use kCFRunLoopCommonModes.</p>
  1227. </div>
  1228. <div class="method-subsection declared-in-section">
  1229. <h4 class="method-subtitle">Declared In</h4>
  1230. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1231. </div>
  1232. </div>
  1233. <div class="section-method">
  1234. <a name="//api/name/setUserData:" title="setUserData:"></a>
  1235. <h3 class="subsubtitle method-title">setUserData:</h3>
  1236. <div class="method-subsection method-declaration"><code>- (void)setUserData:(long)<em>userData</em></code></div>
  1237. </div>
  1238. <div class="section-method">
  1239. <a name="//api/name/startTLS:" title="startTLS:"></a>
  1240. <h3 class="subsubtitle method-title">startTLS:</h3>
  1241. <div class="method-subsection brief-description">
  1242. <p>Secures the connection using SSL/TLS.</p>
  1243. </div>
  1244. <div class="method-subsection method-declaration"><code>- (void)startTLS:(NSDictionary *)<em>tlsSettings</em></code></div>
  1245. <div class="method-subsection discussion-section">
  1246. <h4 class="method-subtitle">Discussion</h4>
  1247. <p>Secures the connection using SSL/TLS.</p>
  1248. <p>This method may be called at any time, and the TLS handshake will occur after all pending reads and writes<br/>
  1249. are finished. This allows one the option of sending a protocol dependent StartTLS message, and queuing<br/>
  1250. the upgrade to TLS at the same time, without having to wait for the write to finish.<br/>
  1251. Any reads or writes scheduled after this method is called will occur over the secured connection.</p>
  1252. <p>The possible keys and values for the TLS settings are well documented.<br/>
  1253. Some possible keys are:<br/>
  1254. - kCFStreamSSLLevel<br/>
  1255. - kCFStreamSSLAllowsExpiredCertificates<br/>
  1256. - kCFStreamSSLAllowsExpiredRoots<br/>
  1257. - kCFStreamSSLAllowsAnyRoot<br/>
  1258. - kCFStreamSSLValidatesCertificateChain<br/>
  1259. - kCFStreamSSLPeerName<br/>
  1260. - kCFStreamSSLCertificates<br/>
  1261. - kCFStreamSSLIsServer</p>
  1262. <p>Please refer to Apple&rsquo;s documentation for associated values, as well as other possible keys.</p>
  1263. <p>If you pass in nil or an empty dictionary, the default settings will be used.</p>
  1264. <p>The default settings will check to make sure the remote party&rsquo;s certificate is signed by a<br/>
  1265. trusted 3rd party certificate agency (e.g. verisign) and that the certificate is not expired.<br/>
  1266. However it will not verify the name on the certificate unless you<br/>
  1267. give it a name to verify against via the kCFStreamSSLPeerName key.<br/>
  1268. The security implications of this are important to understand.<br/>
  1269. Imagine you are attempting to create a secure connection to MySecureServer.com,<br/>
  1270. but your socket gets directed to MaliciousServer.com because of a hacked DNS server.<br/>
  1271. If you simply use the default settings, and MaliciousServer.com has a valid certificate,<br/>
  1272. the default settings will not detect any problems since the certificate is valid.<br/>
  1273. To properly secure your connection in this particular scenario you<br/>
  1274. should set the kCFStreamSSLPeerName property to &ldquo;MySecureServer.com&rdquo;.<br/>
  1275. If you do not know the peer name of the remote host in advance (for example, you&rsquo;re not sure<br/>
  1276. 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/>
  1277. certificate, and then use the X509Certificate class to verify the issuer after the socket has been secured.<br/>
  1278. The X509Certificate class is part of the CocoaAsyncSocket open source project.</p>
  1279. </div>
  1280. <div class="method-subsection declared-in-section">
  1281. <h4 class="method-subtitle">Declared In</h4>
  1282. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1283. </div>
  1284. </div>
  1285. <div class="section-method">
  1286. <a name="//api/name/unreadData" title="unreadData"></a>
  1287. <h3 class="subsubtitle method-title">unreadData</h3>
  1288. <div class="method-subsection brief-description">
  1289. <p>In the event of an error, this method may be called during onSocket:willDisconnectWithError: to read<br/>
  1290. any data that&rsquo;s left on the socket.</p>
  1291. </div>
  1292. <div class="method-subsection method-declaration"><code>- (NSData *)unreadData</code></div>
  1293. <div class="method-subsection discussion-section">
  1294. <h4 class="method-subtitle">Discussion</h4>
  1295. <p>In the event of an error, this method may be called during onSocket:willDisconnectWithError: to read<br/>
  1296. any data that&rsquo;s left on the socket.</p>
  1297. </div>
  1298. <div class="method-subsection declared-in-section">
  1299. <h4 class="method-subtitle">Declared In</h4>
  1300. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1301. </div>
  1302. </div>
  1303. <div class="section-method">
  1304. <a name="//api/name/userData" title="userData"></a>
  1305. <h3 class="subsubtitle method-title">userData</h3>
  1306. <div class="method-subsection method-declaration"><code>- (long)userData</code></div>
  1307. </div>
  1308. <div class="section-method">
  1309. <a name="//api/name/writeData:withTimeout:tag:" title="writeData:withTimeout:tag:"></a>
  1310. <h3 class="subsubtitle method-title">writeData:withTimeout:tag:</h3>
  1311. <div class="method-subsection brief-description">
  1312. <p>Writes data to the socket, and calls the <a href="#//api/name/delegate">delegate</a> when finished.</p>
  1313. </div>
  1314. <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>
  1315. <div class="method-subsection discussion-section">
  1316. <h4 class="method-subtitle">Discussion</h4>
  1317. <p>Writes data to the socket, and calls the <a href="#//api/name/delegate">delegate</a> when finished.</p>
  1318. <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/>
  1319. If the timeout value is negative, the write operation will not use a timeout.</p>
  1320. </div>
  1321. <div class="method-subsection declared-in-section">
  1322. <h4 class="method-subtitle">Declared In</h4>
  1323. <code class="declared-in-ref">AsyncSocket.h</code><br />
  1324. </div>
  1325. </div>
  1326. </div>
  1327. </div>
  1328. <div class="main-navigation navigation-bottom">
  1329. <ul>
  1330. <li><a href="../index.html">Index</a></li>
  1331. <li><a href="../hierarchy.html">Hierarchy</a></li>
  1332. </ul>
  1333. </div>
  1334. <div id="footer">
  1335. <hr />
  1336. <div class="footer-copyright">
  1337. <p><span class="copyright">&copy; 2013 Dustin Voss and Robbie Hanson. All rights reserved. (Last updated: 2013-04-24)</span><br />
  1338. <span class="generator">Generated by <a href="http://appledoc.gentlebytes.com">appledoc 2.1 (build 858)</a>.</span></p>
  1339. </div>
  1340. </div>
  1341. </div>
  1342. </article>
  1343. <script type="text/javascript">
  1344. function jumpToChange()
  1345. {
  1346. window.location.hash = this.options[this.selectedIndex].value;
  1347. }
  1348. function toggleTOC()
  1349. {
  1350. var contents = document.getElementById('contents');
  1351. var tocContainer = document.getElementById('tocContainer');
  1352. if (this.getAttribute('class') == 'open')
  1353. {
  1354. this.setAttribute('class', '');
  1355. contents.setAttribute('class', '');
  1356. tocContainer.setAttribute('class', '');
  1357. window.name = "hideTOC";
  1358. }
  1359. else
  1360. {
  1361. this.setAttribute('class', 'open');
  1362. contents.setAttribute('class', 'isShowingTOC');
  1363. tocContainer.setAttribute('class', 'isShowingTOC');
  1364. window.name = "";
  1365. }
  1366. return false;
  1367. }
  1368. function toggleTOCEntryChildren(e)
  1369. {
  1370. e.stopPropagation();
  1371. var currentClass = this.getAttribute('class');
  1372. if (currentClass == 'children') {
  1373. this.setAttribute('class', 'children open');
  1374. }
  1375. else if (currentClass == 'children open') {
  1376. this.setAttribute('class', 'children');
  1377. }
  1378. return false;
  1379. }
  1380. function tocEntryClick(e)
  1381. {
  1382. e.stopPropagation();
  1383. return true;
  1384. }
  1385. function init()
  1386. {
  1387. var selectElement = document.getElementById('jumpTo');
  1388. selectElement.addEventListener('change', jumpToChange, false);
  1389. var tocButton = document.getElementById('table_of_contents');
  1390. tocButton.addEventListener('click', toggleTOC, false);
  1391. var taskTreeItem = document.getElementById('task_treeitem');
  1392. if (taskTreeItem.getElementsByTagName('li').length > 0)
  1393. {
  1394. taskTreeItem.setAttribute('class', 'children');
  1395. taskTreeItem.firstChild.setAttribute('class', 'disclosure');
  1396. }
  1397. var tocList = document.getElementById('toc');
  1398. var tocEntries = tocList.getElementsByTagName('li');
  1399. for (var i = 0; i < tocEntries.length; i++) {
  1400. tocEntries[i].addEventListener('click', toggleTOCEntryChildren, false);
  1401. }
  1402. var tocLinks = tocList.getElementsByTagName('a');
  1403. for (var i = 0; i < tocLinks.length; i++) {
  1404. tocLinks[i].addEventListener('click', tocEntryClick, false);
  1405. }
  1406. if (window.name == "hideTOC") {
  1407. toggleTOC.call(tocButton);
  1408. }
  1409. }
  1410. window.onload = init;
  1411. // If showing in Xcode, hide the TOC and Header
  1412. if (navigator.userAgent.match(/xcode/i)) {
  1413. document.getElementById("contents").className = "hideInXcode"
  1414. document.getElementById("tocContainer").className = "hideInXcode"
  1415. document.getElementById("top_header").className = "hideInXcode"
  1416. }
  1417. </script>
  1418. </body>
  1419. </html>