TDI Server send function not working

Hi,
i have established TCP/IP communication path between TDI server and TDI client.
But my TDI server’s send function is not working.
Please help me.

My code as follows.

NTSTATUS
Send(PDEVICE_OBJECT pTcpDevObj, PFILE_OBJECT pConnFileObj, PVOID Data, ULONG Length, PSIZE_T total)
{
NTSTATUS status = STATUS_TIMEOUT;
PIRP pIrp;
IO_STATUS_BLOCK IoStatus = {0};

KEVENT SendEvent;
PMDL pMdl;

*total = 0; //To use for received data count

KeInitializeEvent(&SendEvent, NotificationEvent, FALSE);

// build an IRP to connect to a remote host
pIrp =
TdiBuildInternalDeviceControlIrp( TDI_SEND,
pTcpDevObj, // TDI driver’s device object.
pConnFileObj, // Connection (endpoint) file object.
&SendEvent, // Event to be signalled when Irp completes.
&IoStatus // I/O status block.
);

if(NULL==pIrp)
{
DbgPrint(“Could not get an IRP for TDI_SEND”);
return(STATUS_INSUFFICIENT_RESOURCES);
}

// must run at <= DISPATCH_LEVEL
ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL );
pMdl = IoAllocateMdl((PCHAR)Data, Length, FALSE, FALSE, pIrp);
if(NULL==pMdl)
{
DbgPrint(“Could not get an MDL for TDI_SEND”);
return(STATUS_INSUFFICIENT_RESOURCES);
}

// must run at < DISPATCH_LEVEL for pageable memory
ASSERT( KeGetCurrentIrql() < DISPATCH_LEVEL );
__try
{
MmProbeAndLockPages( pMdl, // (Try to) fix buffer.
KernelMode,
IoModifyAccess
);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
DbgPrint(“Exception calling MmProbeAndLockPages”);
IoFreeMdl(pMdl);
pMdl = NULL;
return STATUS_UNSUCCESSFUL;
}

DbgPrint(“Before tdiBuildSend”);
TdiBuildSend( pIrp,
pTcpDevObj, // TDI driver’s device object.
pConnFileObj, // Connection (endpoint) file object.
NULL, // I/O completion routine.
NULL, // Context for I/O completion routine.
pMdl, // MDL address.
0, //TDI_SEND_NON_BLOCKING // Flags. 0 => send as normal TSDU.
Length // Length of buffer mapped by MDL.
);

ASSERT( KeGetCurrentIrql() == PASSIVE_LEVEL );
IoSetCompletionRoutine( pIrp, TDICompletionRoutine, &SendEvent, TRUE, TRUE, TRUE);

ASSERT( KeGetCurrentIrql() <= DISPATCH_LEVEL );
status = IoCallDriver(pTcpDevObj, pIrp);
if (STATUS_PENDING==status)
{
DbgPrint(“Waiting on IRP (send)…”);
status = KeWaitForSingleObject(&SendEvent, Executive, KernelMode, FALSE, 0);
}

if(status != STATUS_SUCCESS) {
DbgPrint(“Send…fails”);
return status;
} else
{
DbgPrint(“n Total sent : %dn”,IoStatus.Information);
*total = IoStatus.Information;
return IoStatus.Status;
}
}

With thanks in advance,
Barun