This is an attempt to address some TCP/IP frequently asked questions and present best practices. While the WinSock Programmer’s FAQ will remain the ultimate FAQ for native code, there is a growing need for a simplified version that addresses the managed interface to TCP/IP sockets.

Section 1 - Application Protocol Design

1.1 - Message framing, also known as:

  “One side sent X bytes, but the other side only got Y bytes.”

  “One side sent several packets, but the other side only got one packet, which was all the sent packets appended together.”

  “I need the function that will send exactly one packet of data.”

1.2 - Detection of half-open (dropped) connections, also known as:

  “My socket doesn’t detect a lost connection; it just sits there forever waiting for more data to arrive.”

1.3 - Application Protocol Specifications

1.4 - XML over TCP/IP

Section 2 - Socket Class

2.1 - Socket operations

2.2 - Error handling

2.3 - Using Socket as a client socket

2.4 - Using Socket as a server (listening) socket

2.5 - Using Socket as a connected socket

Section 3 - Miscellaneous

3.1 - Resources

3.2 - Getting the local IP address

Section C - Code

C.1 - Length-prefix message framing for streams

C.2 - Getting the local IP addresses