I'm writing a single-client (for now) server that has a main loop that interpert client request , and dispatces a proper handler.
for some taks, I'll like to use MS overlapped I/O (it's for windows only) . in one of them, I want to read from a file and write the content to a socket. as I have class wrape for that action, it's allocates a buffer, the size of the file, and then a call to ReadFile (with an actual file-system file) is made, followed by a WriteFile (this time, to a socket handle) both beeing made overlapped.
problem is: as it's async', the class d'tor is beeing called automatically, and the file's buffer get's freed, before the job is done,
obviously, that is a broken design of mine, I really like to hear for a suggestion of your's,
thanks!