close(STDOUT); before the open makes it work (but I don't know why).
In reply to Re: Win32: Redirect STDOUT to socket by ikegami in thread Win32: Redirect STDOUT to socket by repellent