Chapter 1

An Intro to Windows Socket (Winsock2) Programming







What do we have in this chapter?


  1. Winsock Headers and Libraries

  2. Initializing Winsock

  3. Error Checking and Handling

  4. Addressing a Protocol

  5. Addressing IPv4

  6. Internet Addresses

  7. Some Note

  8. inet_ntoa() Function

  9. InetNtop() Function

  10. InetPton() Function

  11. Byte Ordering

  12. Creating a Socket

  13. Connection-Oriented Communication

  14. Server API Functions

  15. Binding, bind()

  16. Listening, listen()

  17. Accepting Connections, accept()

  18. Client API Functions

  19. TCP States

  20. connect()

  21. Data Transmission

  22. send() and WSASend()

  23. WSASendDisconnect()

  24. Out-of-Band Data

  25. recv() and WSARecv()

  26. WSARecvDisconnect()

  27. Stream Protocols

  28. Scatter-Gather I/O

  29. Breaking the Connection

  30. shutdown()

  31. closesocket()

  32. TCP Receiver/Server With select() Example

  33. TCP Sender/client Program Example

  34. Testing the TCP Client and Server Programs

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

  36. Connectionless Communication

  37. Receiver

  38. Sender

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

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

  41. Message-Based Protocols

  42. Releasing Socket Resources

  43. Miscellaneous APIs

  44. getpeername()

  45. getsockname()

  46. WSADuplicateSocket()

  47. Windows CE




In this chapter, we presented the core Winsock functions that are required for connection-oriented and connectionless communication using the TCP and UDP protocols specifically. For connection-oriented communication, we demonstrated how to accept a client connection and how to establish a client connection to a server. We covered the semantics for session-oriented data-send operations and data-receive operations. For connectionless communication, we also described how to send and receive data. Since this chapter was designed to introduce the core Winsock APIs, we did not address network programming performance considerations. Later, we will address performance issues and introduce the Microsoft Winsock extensions TransmitFile(), TransmitPackets(), AcceptEx(), GetAcceptExSockaddrs(), ConnectEx(), DisconnectEx(), and WSARecvMsg(), which can help you write high performance, scalable Winsock applications. Our discussions so far have demonstrated using Winsock with just the IPv4 protocol.







Custom Search

< Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7 | Chap 2: Protocol Characteristics >