Unless Windows behaves very differently from Unix, you shouldn't need to set SO_LINGER for this. By default all data will be sent when the socket is close'd. I'd start by looking elsewhere for the bug, and possibly implementing a very very small program to see if it can reproduce the problem. If you can reproduce it in a few lines, post what you come up with.