ÿþ<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=unicode" /> <meta http-equiv="Content-Language" content="en-us" /> <title>An introduction to the Windows Socket 2 (Winsock2) programming tutorials with code and program example</title> <meta name="keywords" content="network, networking, protocol, UDP, TCP, security, communication, technology, devices, hacking, data, packets, examples, programs, sample codes" /> <meta name="description" content="A complete and the best Winsock2 Win32 programming tutorials with working program examples and console output" /> </head> <body topmargin="20" leftmargin="20" rightmargin="20" bottommargin="20"> <table border="0" width="100%"> <tr> <td colspan="2"> <h1 align="center" style="margin-top:0; margin-bottom:0"> <font face="Batang"><span style="font-weight: 400">The Windows Socket 2 (Winsock2) Programming</span></font></h1> </td> </tr> <tr> <td colspan="2"> <p align="center"> <script type="text/javascript"><!-- google_ad_client = "pub-8089415323104206"; google_ad_slot = "2156170134"; google_ad_width = 728; google_ad_height = 15; //--> </script> &nbsp;<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></p> </td> </tr> <tr> <td width="7%" align="center"> <h3> <font face="Byington"><span style="font-weight: 400"> <a title="The Win32 programming tutorial using Visual Studio, C and C++ languages" target="_top" href="index.html"> HOME</a></span></font></h3> <p>&nbsp;</p> <p>&nbsp;</p> <div align="center"> <script src="http://tag.contextweb.com/TagPublish/getjs.aspx?action=VIEWAD&cwrun=200&cwadformat=160X600&cwpid=527221&cwwidth=160&cwheight=600&cwpnet=1&cwtagid=82739"></script> </div> <p>&nbsp;</p> <p>&nbsp;</p> <p> <script type="text/javascript"><!-- google_ad_client = "pub-8089415323104206"; google_ad_slot = "3614899554"; google_ad_width = 160; google_ad_height = 600; //--> </script> &nbsp;<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></p> </td> <td width="92%"> <h1 style="margin-bottom:0mm;margin-bottom:0; margin-top:0"> <font size="5" face="Times New Roman"> <span style="line-height:115%; font-family:&quot;Arial&quot;; font-weight:400">What do we have in this session?</span></font></h1> <p style="margin-bottom:0mm;margin-bottom:0; margin-top:0"> &nbsp;</p> <p style="margin-bottom:0mm;margin-bottom:0; margin-top:0"> <font face="Arial">This tutorial provides a kick start on Windows socket (Winsock) programming. It is not in depth tutorial, provided here as an introduction on the programming environment setup for Winsock 2. The advanced topics (and code examples) for Winsock 2 using C can be found at <a title="Windows network programming for fun using C language" target="_blank" href="http://www.winsocketdotnetworkprogramming.com/winsock2programming/"> Winsock2 programming</a> and the .NET version also available at <a title="windows .NET network programming tutorial with C#, C++/CLI and VB .NET code samples" target="_top" href="http://www.winsocketdotnetworkprogramming.com/"> .NET network programming</a> (with C#, VB .NET and C++/CLI examples).</font></p> <ol> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214.html">Introduction</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_1.html">Winsock Headers and Libraries</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Initializing Winsock</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_2.html">Error Checking and Handling</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_3.html">Addressing a Protocol</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Addressing IPv4</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Internet Addresses</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Some Note</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_4.html">inet_ntoa() Function</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">InetNtop() Function</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">InetPton() Function</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_5.html">Byte Ordering</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Creating a Socket</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Connection-Oriented Communication</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_6.html">Server API Functions</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Binding, bind()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Listening, listen()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Accepting Connections, accept()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"> <span style="font-weight: 400"><font face="Byington"> <a href="windowsocketwinsock214_7.html">Server Program Example</a></font></span></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_8.html">Client API Functions</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">TCP States</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">connect()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"> <span style="font-weight: 400"><font face="Byington"> <a href="windowsocketwinsock214_9.html">Client Program Example</a></font></span></h3> </li> </ol> <p style="margin-bottom:0; margin-top:0">&nbsp;</p> <p style="margin-bottom:0; margin-top:0">&nbsp;</p> <div align="center"> <script src="http://tag.contextweb.com/TagPublish/getjs.aspx?action=VIEWAD&cwrun=200&cwadformat=728X90&cwpid=527221&cwwidth=728&cwheight=90&cwpnet=1&cwtagid=82740"></script> </div> <p style="margin-top: 0; margin-bottom: 0"></p> <p style="margin-bottom:0; margin-top:0">&nbsp;</p> <ol start="24"> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_10.html">Data Transmission</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">send() and WSASend()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">WSASendDisconnect()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Out-of-Band Data</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">recv() and WSARecv()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">WSARecvDisconnect()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_11.html">Stream Protocols</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Scatter-Gather I/O</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Breaking the Connection</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">shutdown()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">closesocket()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_12.html">TCP Receiver/Server With select() Example</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_13.html">TCP Sender/client Program Example</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_14.html">Testing the TCP Client and Server Programs</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_15.html">Testing the TCP Client and Server Programs in Private Network</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_16.html">Connectionless Communication</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Receiver</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_17.html">Sender</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_18.html">Running Both the UDP Receiver/Server and UDP Sender/Client</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400"> <a href="windowsocketwinsock214_19.html">Testing the UDP Client and select Server Programs in Private Network</a></span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Message-Based Protocols</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Releasing Socket Resources</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Miscellaneous APIs</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">getpeername()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">getsockname()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">WSADuplicateSocket()</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Windows CE</span></font></h3> </li> <li> <h3 style="margin-bottom:0; margin-top:0"><font face="Byington"> <span style="font-weight: 400">Conclusion</span></font></h3> </li> </ol> </td> </tr> <tr> <td colspan="2"> <p align="center"> <script type="text/javascript"><!-- google_ad_client = "pub-8089415323104206"; google_ad_slot = "0761177910"; google_ad_width = 728; google_ad_height = 90; //--> </script> &nbsp;<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></p> </td> </tr> <tr> <td colspan="2"> <h3 align="center" style="margin-top: 0; margin-bottom: 0"> <font face="Byington"><span style="font-weight: 400">&lt; <a title="The Windows Station &amp; Desktop Win32 Programming tutorials with code sample and program examples" style="color: blue; text-decoration: underline" href="windowstationsdesktops13index.html"> Windows Station and Desktop</a> | <a title="The Win32 programming tutorial using Visual Studio, C and C++ languages" style="color: blue; text-decoration: underline" href="index.html"> Win32 Programming</a> | <a title="A complete and the best Windows socket (Winsock2) programming with working program examples" style="color: blue; text-decoration: underline" href="windowsocketwinsock214.html"> Winsock2 1</a> &gt;</span></font></h3> </td> </tr> </table> </body> </html>