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

Stephen, this is some very helpful documentation you have put together hear. Thanks very much for your efforts!
ReplyDeleteFantastic article, really appreciate your work here. It's just a shame I've already encountered most of the pitfalls.
ReplyDeleteHello,
ReplyDeleteI've been able to program using sockets for a long time but I have never completely understood them. This really demystified everything I had questions about (such as the backlog on a socket's listening function). I'm very excited for my current project as I feel I'll be able to make it better just by reading what you've wrote.
Very good work!
ReplyDeleteExcellent work, thank you!
ReplyDeleteIf only I read this article a 2 years ago, would have saved me a lot of headaches. Great work!
ReplyDeleteThis is brilliant! Thank you so much!
ReplyDelete