You may also want to set some socket options, i.e. turn off Nagle's algorithm. See setsockopt and TCP_NODELAY. You can also set the socket buffer size to zero using SO_RCVBUF and SO_SNDBUF options. Setting SO_SNDBUF to 0 on Windows bypasses the OS's TCP/IP stack buffer. Perhaps this problem is more suited to C++? Let us know how you get on.
Comment on Re: Network Reliability Testing, problems with buffered sockets?