Hi All,

I have a driver that is using TCP via TDI. On occasion I have need to call
IoCancelIrp on a TDI Send IRP. Unfortunately, the TCP code closes down the
connection when IoCancelIrp is called. I got a hold of Microsoft and an
engineer there said that that was the appropriate behavior he found in the
TCP code. I wish they had left it to the driver author to decide. The
engineer said there were no flag overrides. I do have a work around for this.

However, let's say I want to send 100 bytes. The last ACK from the device
I'm communicating with sent a window size of 22 bytes. TCP will send the 22
bytes and the ACK back from the device now states a window size of 0. TCP
will not send anymore data until the device communicates back with a window
size greater than zero. In the mean time, I timeout the write and cancel the
IRP via IoCancelIrp. The write completion routine fires with a code of
STATUS_CANCELLED. All as expected.

Here is the problem. the Irp->IoStatus.Information in the write complete
contains a 0. I expected 22. Does anyone know of a way to query TDI/TCP
about the number of partial bytes sent? I need to do some reconnecting and
resending. But if I don't know how much data from the cancelled IRP was
sent, I'm sunk. I tried using the TdiBuildQueryInformation with
TDI_QUERY_PROVIDER_STATISTICS on the connection object to get some
information, but most of the fields are zero.

Also, applications that call my driver set up the write timeout, so I need
to honor the timeouts. Also, the application may resend the data or close
the port. If I knew how much data was sent then I could handle the situation.

Thanks in advance,
-David G

Re: TCP using TDI and IoCancelIrp by Maxim

Maxim
Fri Jun 23 14:38:33 CDT 2006

> Here is the problem. the Irp->IoStatus.Information in the write complete
> contains a 0. I expected 22. Does anyone know of a way to query TDI/TCP
> about the number of partial bytes sent? I need to do some reconnecting and

TCP does not support the notion of "partial bytes sent". Either you wait till
all bytes will be sent - or you abort the connection, no other ways.

That's why cancelling any TDI_SEND to TCP causes the connection abort, this is
very, very correct.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com