DISK I/O
Set a ioCompletion routine
Is there any way to send a parameter to an ioCompletion routine for the device manager? I have multiple TCP streams, more than one of which may be opening simultaneously, and I would like the completion procedure to know which one opened. If a parameter can't be passed, can someone suggest an alternate way of accomplishing this?
Well, here's what you _could_ do. Keep an array or linked list of the TCP ref numbers for the streams you are opening. I'd probably use a linked list and then store more about it then just the refnumber (so as not to waste the list) and so that it was entirely flexible. Then, have one ioCompletion routine where the first lines of code looped through the available TCP streams and checked to see if they were open (by using the TCP status routines). I'd probably have a field that was the TCP connection's state _before_ the current check that way you can tell if a connection had just been finished.
Maybe something like this:
DIM RECORD myTCPInfo
DIM tcpRefNum%
DIM LastState%
DIM CurrState%
DIM otherData&
DIM NextElement&
DIM END RECORD .TCPInfoSize
This is maybe not the best, but I just got back from a theme park :) Anyway, with this you could keep track of the the changes in the TCP connection and when a completion routine got called it could check to see which stream completed by looping through each one element. If it found one where the lastState was _connecting and the currState was _connected (or _failed) then that would be the one that called the completion routine. Obviously, those are my own constants :)
|