Leaked source code of windows server 2003
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
10 KiB

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 10">
<meta name=Originator content="Microsoft Word 10">
<link rel=File-List href="blaster_files/filelist.xml">
<title>BLASTER - Winsock IrDA Sample Application</title>
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:Zoom>97</w:Zoom>
<w:SpellingState>Clean</w:SpellingState>
<w:GrammarState>Clean</w:GrammarState>
<w:Compatibility>
<w:UseFELayout/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;
mso-font-charset:0;
mso-generic-font-family:modern;
mso-font-format:other;
mso-font-pitch:fixed;
mso-font-signature:3 0 0 0 1 0;}
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;
mso-font-charset:2;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
{font-family:"MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;
mso-font-alt:"\FF2D\FF33 \660E\671D";
mso-font-charset:128;
mso-generic-font-family:modern;
mso-font-pitch:fixed;
mso-font-signature:-1610612033 1757936891 16 0 131231 0;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:536871559 0 0 0 415 0;}
@font-face
{font-family:"\@MS Mincho";
panose-1:2 2 6 9 4 2 5 8 3 4;
mso-font-charset:128;
mso-generic-font-family:modern;
mso-font-pitch:fixed;
mso-font-signature:-1610612033 1757936891 16 0 131231 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"MS Mincho";}
p
{font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"MS Mincho";}
pre
{margin-top:0in;
margin-bottom:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
mso-fareast-font-family:"MS Mincho";}
span.SpellE
{mso-style-name:"";
mso-spl-e:yes;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:2081251339;
mso-list-template-ids:-1945449268;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:.5in;
mso-level-number-position:left;
text-indent:-.25in;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->
</head>
<body lang=EN-US style='tab-interval:.5in'>
<div class=Section1>
<h2><span style='font-family:Verdana'>BLASTER – Winsock IrDA Sample Application<o:p></o:p></span></h2>
<h3><span style='font-family:Verdana'>SUMMARY<o:p></o:p></span></h3>
<p><span style='font-size:10.0pt;font-family:Verdana'>Blaster is a simple
application that illustrates Windows NT 5.0’s support of the IrDA protocol.
IrDA provides reliable point to point connectivity between 2 computers equipped
with infrared transceivers. Blaster uses the WinSock API with the IrDA address
family to setup a single connection and &quot;blast&quot; random data to a peer
machine that is also running blaster.<o:p></o:p></span></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>Blaster can be used
during the development of Winsock application or OEM IrDA NDIS drivers to get
an initial impression of performance.<o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>BUILDING THE SAMPLE<o:p></o:p></span></h3>
<p><span style='font-size:10.0pt;font-family:Verdana'>To build BLASTER.EXE,
select either the checked or free DDK environment, change to the directory
BLASTER and type BUILD.<o:p></o:p></span></p>
<p><b style='mso-bidi-font-weight:normal'><span style='font-size:13.5pt;
font-family:Verdana'>RUNNING THE SAMPLE<o:p></o:p></span></b></p>
<p><span style='font-size:10.0pt;font-family:Verdana'>Copy BLASTER.EXE the test
machine and run it.<o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>RESOURCES<o:p></o:p></span></h3>
<p><span style='font-size:10.0pt;font-family:Verdana'>IrDA Winsock applications
are discussed in greater detail in the .DOC files included in the IrDA section
of the DDK samples. <o:p></o:p></span></p>
<h3><span style='font-family:Verdana'>CODE TOUR<o:p></o:p></span></h3>
<h4><span style='font-family:Verdana'>File Manifest<o:p></o:p></span></h4>
<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
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
style='font-family:Courier'><o:p></o:p></span></pre><pre><span class=GramE><span
style='font-family:Courier'>BLASTER.C<span style='mso-spacerun:yes'>     </span>The Source for blaster.</span></span><span
style='font-family:Courier'><o:p></o:p></span></pre><pre><span
style='font-family:Courier'>BLASTER.RC<span style='mso-spacerun:yes'>    </span>The <span
class=GramE>resource file</span> for blaster.<o:p></o:p></span></pre><pre><span
class=GramE><span style='font-family:Courier'>MAKEFILE<span style='mso-spacerun:yes'>      </span>The standard DDK <span
class=SpellE>makefile</span>.</span></span><span style='font-family:Courier'><o:p></o:p></span></pre><pre><span
style='font-family:Courier'>RESOURCE.H<span style='mso-spacerun:yes'>    </span>C Defines for blaster.<o:p></o:p></span></pre><pre><span
style='font-family:Courier'>RESRC1.H<span style='mso-spacerun:yes'>      </span>More C Defines.<o:p></o:p></span></pre>
<h4><span style='font-family:Verdana'>Programming Tour<o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>The major topics covered
in this tour are: <o:p></o:p></span></p>
<ul type=disc>
<li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
mso-list:l0 level1 lfo1;tab-stops:list .5in'><span style='font-size:10.0pt;
font-family:Verdana'>Enumerating Visible Devices <o:p></o:p></span></li>
<li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
mso-list:l0 level1 lfo1;tab-stops:list .5in'><span style='font-size:10.0pt;
font-family:Verdana'>Bind()<o:p></o:p></span></li>
</ul>
<p><span style='font-size:10.0pt;font-family:Verdana'>The majority of code in
this sample is actually devoted to window setup. The heart of the application
and the source of most interest to the reader are the functions <span
class=SpellE><span class=GramE><b>SendThread</b></span></span><span
class=GramE><b>(</b></span><b>)</b> and <span class=SpellE><b>RecvThread</b></span><b>()</b>.
All of the functionality required for IrDA connections are encapsulated there.
The application itself is very simple. On startup, <span class=SpellE><span
class=GramE><b>RecvThread</b></span></span><span class=GramE><b>(</b></span><b>)</b>
creates a socket to listen for incoming IrDA connections. When the user clicks
the only button in the interface, <span class=SpellE><span class=GramE><b>SendThread</b></span></span><span
class=GramE><b>(</b></span><b>)</b> is invoked to enumerate available devices
and establish a connection with the first visible device. It will proceed to ‘blast’
data through this connection, and then close it.<o:p></o:p></span></p>
<h4><span style='font-family:Verdana'>Enumerating Visible Devices<o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Infrared Devices which
are in range will be enumerated when the user calls <span class=SpellE><span
class=GramE><b>getsockopt</b></span></span><span class=GramE><b>(</b></span><b>)</b>
with the parameters of <b>SOL_IRLMP</b> and <b>IRLMP_ENUMDEVICES</b>. Note that
no special coding is required if the computer has more than one IrDA adapter.
The protocol will automatically query for all visible devices on all IrDA
adapters present, and return them in a single call. Note that if a device is
visible to more than one adapter, it may be presented twice in the list.<o:p></o:p></span></p>
<h4><span class=GramE><span style='font-family:Verdana'>Bind()</span></span><span
style='font-family:Verdana'><o:p></o:p></span></h4>
<p><span style='font-size:10.0pt;font-family:Verdana'>Special notice is made
here that, unlike other Winsock protocol families, no call to <span
class=GramE><b>bind(</b></span><b>)</b> is required before calling <b>connect()</b>.
<span class=GramE><b>Bind(</b></span><b>)</b> is normally used to insure the
socket is correctly bound to a local address, generally for cases of multiple
local adapters. The IrDA protocol abstracts multiple adapters so that this is
not necessary. All context information needed to force the connection through
the correct adapter is contained in the <b>SOCKADDR_IRDA</b> structure provided
to <span class=GramE><b>connect(</b></span><b>)</b>, in these fields: <span
class=SpellE><b>irdaDeviceID</b></span> and <span class=SpellE><b>irdaDeviceName</b></span>.
If you do attempt to <span class=GramE><b>bind(</b></span><b>)</b> on an
outbound connection, the <b>connect() </b>will return an error.<o:p></o:p></span></p>
</div>
</body>
</html>