Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
9.9 KiB

  1. <html xmlns:o="urn:schemas-microsoft-com:office:office"
  2. xmlns:w="urn:schemas-microsoft-com:office:word"
  3. xmlns="http://www.w3.org/TR/REC-html40">
  4. <head>
  5. <meta http-equiv=Content-Type content="text/html; charset=windows-1252">
  6. <meta name=ProgId content=Word.Document>
  7. <meta name=Generator content="Microsoft Word 10">
  8. <meta name=Originator content="Microsoft Word 10">
  9. <link rel=File-List href="blaster_files/filelist.xml">
  10. <title>BLASTER - Winsock IrDA Sample Application</title>
  11. <!--[if gte mso 9]><xml>
  12. <w:WordDocument>
  13. <w:Zoom>97</w:Zoom>
  14. <w:SpellingState>Clean</w:SpellingState>
  15. <w:GrammarState>Clean</w:GrammarState>
  16. <w:Compatibility>
  17. <w:UseFELayout/>
  18. </w:Compatibility>
  19. <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
  20. </w:WordDocument>
  21. </xml><![endif]-->
  22. <style>
  23. <!--
  24. /* Font Definitions */
  25. @font-face
  26. {font-family:Courier;
  27. panose-1:2 7 4 9 2 2 5 2 4 4;
  28. mso-font-charset:0;
  29. mso-generic-font-family:modern;
  30. mso-font-format:other;
  31. mso-font-pitch:fixed;
  32. mso-font-signature:3 0 0 0 1 0;}
  33. @font-face
  34. {font-family:Wingdings;
  35. panose-1:5 0 0 0 0 0 0 0 0 0;
  36. mso-font-charset:2;
  37. mso-generic-font-family:auto;
  38. mso-font-pitch:variable;
  39. mso-font-signature:0 268435456 0 0 -2147483648 0;}
  40. @font-face
  41. {font-family:"MS Mincho";
  42. panose-1:2 2 6 9 4 2 5 8 3 4;
  43. mso-font-alt:"\FF2D\FF33 \660E\671D";
  44. mso-font-charset:128;
  45. mso-generic-font-family:modern;
  46. mso-font-pitch:fixed;
  47. mso-font-signature:-1610612033 1757936891 16 0 131231 0;}
  48. @font-face
  49. {font-family:Verdana;
  50. panose-1:2 11 6 4 3 5 4 4 2 4;
  51. mso-font-charset:0;
  52. mso-generic-font-family:swiss;
  53. mso-font-pitch:variable;
  54. mso-font-signature:536871559 0 0 0 415 0;}
  55. @font-face
  56. {font-family:"\@MS Mincho";
  57. panose-1:2 2 6 9 4 2 5 8 3 4;
  58. mso-font-charset:128;
  59. mso-generic-font-family:modern;
  60. mso-font-pitch:fixed;
  61. mso-font-signature:-1610612033 1757936891 16 0 131231 0;}
  62. /* Style Definitions */
  63. p.MsoNormal, li.MsoNormal, div.MsoNormal
  64. {mso-style-parent:"";
  65. margin:0in;
  66. margin-bottom:.0001pt;
  67. mso-pagination:widow-orphan;
  68. font-size:12.0pt;
  69. font-family:"Times New Roman";
  70. mso-fareast-font-family:"MS Mincho";}
  71. p
  72. {font-size:12.0pt;
  73. font-family:"Times New Roman";
  74. mso-fareast-font-family:"MS Mincho";}
  75. pre
  76. {margin-top:0in;
  77. margin-bottom:0in;
  78. margin-bottom:.0001pt;
  79. font-size:10.0pt;
  80. font-family:"Courier New";
  81. mso-fareast-font-family:"MS Mincho";}
  82. span.SpellE
  83. {mso-style-name:"";
  84. mso-spl-e:yes;}
  85. span.GramE
  86. {mso-style-name:"";
  87. mso-gram-e:yes;}
  88. @page Section1
  89. {size:8.5in 11.0in;
  90. margin:1.0in 1.25in 1.0in 1.25in;
  91. mso-header-margin:.5in;
  92. mso-footer-margin:.5in;
  93. mso-paper-source:0;}
  94. div.Section1
  95. {page:Section1;}
  96. /* List Definitions */
  97. @list l0
  98. {mso-list-id:2081251339;
  99. mso-list-template-ids:-1945449268;}
  100. @list l0:level1
  101. {mso-level-number-format:bullet;
  102. mso-level-text:\F0B7;
  103. mso-level-tab-stop:.5in;
  104. mso-level-number-position:left;
  105. text-indent:-.25in;
  106. mso-ansi-font-size:10.0pt;
  107. font-family:Symbol;}
  108. ol
  109. {margin-bottom:0in;}
  110. ul
  111. {margin-bottom:0in;}
  112. -->
  113. </style>
  114. <!--[if gte mso 10]>
  115. <style>
  116. /* Style Definitions */
  117. table.MsoNormalTable
  118. {mso-style-name:"Table Normal";
  119. mso-tstyle-rowband-size:0;
  120. mso-tstyle-colband-size:0;
  121. mso-style-noshow:yes;
  122. mso-style-parent:"";
  123. mso-padding-alt:0in 5.4pt 0in 5.4pt;
  124. mso-para-margin:0in;
  125. mso-para-margin-bottom:.0001pt;
  126. mso-pagination:widow-orphan;
  127. font-size:10.0pt;
  128. font-family:"Times New Roman";}
  129. </style>
  130. <![endif]-->
  131. </head>
  132. <body lang=EN-US style='tab-interval:.5in'>
  133. <div class=Section1>
  134. <h2><span style='font-family:Verdana'>BLASTER � Winsock IrDA Sample Application<o:p></o:p></span></h2>
  135. <h3><span style='font-family:Verdana'>SUMMARY<o:p></o:p></span></h3>
  136. <p><span style='font-size:10.0pt;font-family:Verdana'>Blaster is a simple
  137. application that illustrates Windows NT 5.0�s support of the IrDA protocol.
  138. IrDA provides reliable point to point connectivity between 2 computers equipped
  139. with infrared transceivers. Blaster uses the WinSock API with the IrDA address
  140. family to setup a single connection and &quot;blast&quot; random data to a peer
  141. machine that is also running blaster.<o:p></o:p></span></p>
  142. <p><span style='font-size:10.0pt;font-family:Verdana'>Blaster can be used
  143. during the development of Winsock application or OEM IrDA NDIS drivers to get
  144. an initial impression of performance.<o:p></o:p></span></p>
  145. <h3><span style='font-family:Verdana'>BUILDING THE SAMPLE<o:p></o:p></span></h3>
  146. <p><span style='font-size:10.0pt;font-family:Verdana'>To build BLASTER.EXE,
  147. select either the checked or free DDK environment, change to the directory
  148. BLASTER and type BUILD.<o:p></o:p></span></p>
  149. <p><b style='mso-bidi-font-weight:normal'><span style='font-size:13.5pt;
  150. font-family:Verdana'>RUNNING THE SAMPLE<o:p></o:p></span></b></p>
  151. <p><span style='font-size:10.0pt;font-family:Verdana'>Copy BLASTER.EXE the test
  152. machine and run it.<o:p></o:p></span></p>
  153. <h3><span style='font-family:Verdana'>RESOURCES<o:p></o:p></span></h3>
  154. <p><span style='font-size:10.0pt;font-family:Verdana'>IrDA Winsock applications
  155. are discussed in greater detail in the .DOC files included in the IrDA section
  156. of the DDK samples. <o:p></o:p></span></p>
  157. <h3><span style='font-family:Verdana'>CODE TOUR<o:p></o:p></span></h3>
  158. <h4><span style='font-family:Verdana'>File Manifest<o:p></o:p></span></h4>
  159. <pre><u>Files<span style='mso-spacerun:yes'>�������� </span>Description<o:p></o:p></u></pre><pre>BLASTER.HTM<span style='mso-spacerun:yes'>�� </span>The documentation for this sample (this file).</pre><pre><span
  160. class=GramE><span style='font-family:Courier'>SOURCES<span style='mso-spacerun:yes'>������ </span>The generic file for building the code sample.</span></span><span
  161. style='font-family:Courier'><o:p></o:p></span></pre><pre><span class=GramE><span
  162. style='font-family:Courier'>BLASTER.C<span style='mso-spacerun:yes'>���� </span>The Source for blaster.</span></span><span
  163. style='font-family:Courier'><o:p></o:p></span></pre><pre><span
  164. style='font-family:Courier'>BLASTER.RC<span style='mso-spacerun:yes'>��� </span>The <span
  165. class=GramE>resource file</span> for blaster.<o:p></o:p></span></pre><pre><span
  166. class=GramE><span style='font-family:Courier'>MAKEFILE<span style='mso-spacerun:yes'>����� </span>The standard DDK <span
  167. class=SpellE>makefile</span>.</span></span><span style='font-family:Courier'><o:p></o:p></span></pre><pre><span
  168. style='font-family:Courier'>RESOURCE.H<span style='mso-spacerun:yes'>��� </span>C Defines for blaster.<o:p></o:p></span></pre><pre><span
  169. style='font-family:Courier'>RESRC1.H<span style='mso-spacerun:yes'>����� </span>More C Defines.<o:p></o:p></span></pre>
  170. <h4><span style='font-family:Verdana'>Programming Tour<o:p></o:p></span></h4>
  171. <p><span style='font-size:10.0pt;font-family:Verdana'>The major topics covered
  172. in this tour are: <o:p></o:p></span></p>
  173. <ul type=disc>
  174. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  175. mso-list:l0 level1 lfo1;tab-stops:list .5in'><span style='font-size:10.0pt;
  176. font-family:Verdana'>Enumerating Visible Devices <o:p></o:p></span></li>
  177. <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
  178. mso-list:l0 level1 lfo1;tab-stops:list .5in'><span style='font-size:10.0pt;
  179. font-family:Verdana'>Bind()<o:p></o:p></span></li>
  180. </ul>
  181. <p><span style='font-size:10.0pt;font-family:Verdana'>The majority of code in
  182. this sample is actually devoted to window setup. The heart of the application
  183. and the source of most interest to the reader are the functions <span
  184. class=SpellE><span class=GramE><b>SendThread</b></span></span><span
  185. class=GramE><b>(</b></span><b>)</b> and <span class=SpellE><b>RecvThread</b></span><b>()</b>.
  186. All of the functionality required for IrDA connections are encapsulated there.
  187. The application itself is very simple. On startup, <span class=SpellE><span
  188. class=GramE><b>RecvThread</b></span></span><span class=GramE><b>(</b></span><b>)</b>
  189. creates a socket to listen for incoming IrDA connections. When the user clicks
  190. the only button in the interface, <span class=SpellE><span class=GramE><b>SendThread</b></span></span><span
  191. class=GramE><b>(</b></span><b>)</b> is invoked to enumerate available devices
  192. and establish a connection with the first visible device. It will proceed to �blast�
  193. data through this connection, and then close it.<o:p></o:p></span></p>
  194. <h4><span style='font-family:Verdana'>Enumerating Visible Devices<o:p></o:p></span></h4>
  195. <p><span style='font-size:10.0pt;font-family:Verdana'>Infrared Devices which
  196. are in range will be enumerated when the user calls <span class=SpellE><span
  197. class=GramE><b>getsockopt</b></span></span><span class=GramE><b>(</b></span><b>)</b>
  198. with the parameters of <b>SOL_IRLMP</b> and <b>IRLMP_ENUMDEVICES</b>. Note that
  199. no special coding is required if the computer has more than one IrDA adapter.
  200. The protocol will automatically query for all visible devices on all IrDA
  201. adapters present, and return them in a single call. Note that if a device is
  202. visible to more than one adapter, it may be presented twice in the list.<o:p></o:p></span></p>
  203. <h4><span class=GramE><span style='font-family:Verdana'>Bind()</span></span><span
  204. style='font-family:Verdana'><o:p></o:p></span></h4>
  205. <p><span style='font-size:10.0pt;font-family:Verdana'>Special notice is made
  206. here that, unlike other Winsock protocol families, no call to <span
  207. class=GramE><b>bind(</b></span><b>)</b> is required before calling <b>connect()</b>.
  208. <span class=GramE><b>Bind(</b></span><b>)</b> is normally used to insure the
  209. socket is correctly bound to a local address, generally for cases of multiple
  210. local adapters. The IrDA protocol abstracts multiple adapters so that this is
  211. not necessary. All context information needed to force the connection through
  212. the correct adapter is contained in the <b>SOCKADDR_IRDA</b> structure provided
  213. to <span class=GramE><b>connect(</b></span><b>)</b>, in these fields: <span
  214. class=SpellE><b>irdaDeviceID</b></span> and <span class=SpellE><b>irdaDeviceName</b></span>.
  215. If you do attempt to <span class=GramE><b>bind(</b></span><b>)</b> on an
  216. outbound connection, the <b>connect() </b>will return an error.<o:p></o:p></span></p>
  217. </div>
  218. </body>
  219. </html>