The Windows Socket 2 (Winsock2) Programming








What do we have in this session?


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 Winsock2 programming and the .NET version also available at .NET network programming (with C#, VB .NET and C++/CLI examples).

  1. Introduction

  2. Winsock Headers and Libraries

  3. Initializing Winsock

  4. Error Checking and Handling

  5. Addressing a Protocol

  6. Addressing IPv4

    Internet Addresses

    Some Note

  7. inet_ntoa() Function

  8. InetNtop() Function

    InetPton() Function

  9. Byte Ordering

  10. Creating a Socket

    Connection-Oriented Communication

  11. Server API Functions

  12. Binding, bind()

    Listening, listen()

    Accepting Connections, accept()

  13. Server Program Example

  14. Client API Functions

  15. TCP States


  16. Client Program Example




  1. Data Transmission

  2. send() and WSASend()


    Out-of-Band Data

    recv() and WSARecv()


  3. Stream Protocols

  4. Scatter-Gather I/O

    Breaking the Connection



  5. TCP Receiver/Server With select() Example

  6. TCP Sender/client Program Example

  7. Testing the TCP Client and Server Programs

  8. Testing the TCP Client and Server Programs in Private Network

  9. Connectionless Communication

  10. Receiver

  11. Sender

  12. Running Both the UDP Receiver/Server and UDP Sender/Client

  13. Testing the UDP Client and select Server Programs in Private Network

  14. Message-Based Protocols

    Releasing Socket Resources

    Miscellaneous APIs




    Windows CE


< Windows Station and Desktop | Win32 Programming | Winsock2 1 >