I'm no clarevoyant (by far) but I can't see whether the method you came across is part of Bmax standard.
Anyway, really need to offer some code but, at a guess, can't you use the autoclose feature of CreateSocketStream?
Anyway, really need to offer some code but, at a guess, can't you use the autoclose feature of CreateSocketStream?