htg01
驱动牛犊
驱动牛犊
  • 注册日期2002-12-24
  • 最后登录2008-05-23
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1078回复:1

TDI KStreamSocket的问题,大家看看,我哪里错了

楼主#
更多 发布于:2003-07-03 15:50
我修改得列子,我发现第一次收发数据成功,Socket就断了,怎么回事呢??  就打印这个了  DbgPrint(\"I am away!\\n\");
NTSTATUS Daytime::DriverEntry(PUNICODE_STRING RegistryPath)
{
SetPoolTag(\' weN\');

// Initialize the TDIClient framework first
if (!KTDInterface::Initialize())
{
return STATUS_NOT_FOUND; // something wrong with TDI
}

// Create our client socket
m_pSocket = new CDaytimeSocket;

    // If succeeded - enable network events
KeInitializeEvent(&event, NotificationEvent, FALSE);
   KeResetEvent(&event);

    if (m_pSocket && m_pSocket->IsCreated()) {
        m_pSocket->SetEvents(TRUE);
        DbgPrint(\"Daytime device: started at TCP port %u\\n\", m_pSocket->QueryPort());
    }
    else {
        DbgPrint(\"Daytime: Failed to start\\n\");
        return STATUS_INSUFFICIENT_RESOURCES;
    }
    TDI_ADDRESS_IP addr = {htons(80), SERVER_US_NAVAL_OBSERVATORY};
    CTDI_CONNECTION_INFORMATION server(addr);

    TDI_STATUS status = m_pSocket->connect(server, DAYTIME_QUERY_PERIOD/2);
    if (status != TDI_PENDING && status != TDI_SUCCESS)
       DbgPrint(\"Daytime: Failed to initiate connection due to err %X\\n\", status);
LARGE_INTEGER timeout;
timeout.QuadPart=-4*10000000;
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE,&timeout);
    //if(m_pSocket->IsConnected())
m_pSocket->send(\"get \\n\\n\",7,NULL);
//else DbgPrint(\"it is disconnected!\\n\");
  
    // Init 1st query


return STATUS_SUCCESS;
}

void CDaytimeSocket::OnDisconnect(uint OptionsLength, PVOID Options, BOOLEAN bAbort)
{
    // OK: server disconnects, according to the RFC. Schedule next query.
    DbgPrint(\"I am away!\\n\");
//ScheduleQuery();
}

uint CDaytimeSocket::OnReceive(uint Indicated, uchar *Data,
uint Available, uchar **RcvBuffer, uint* RcvBufferLen)
{
UNREFERENCED_PARAMETERS3(Available, RcvBuffer, RcvBufferLen); // no need in this simple proto

    // Data from the server. It must be the ascii GMT, so print it.
    // NOTE that the server\'s string is NOT null-terminated, so
    // we put 0 at the end.

    Data[Indicated-1]=0;
    DbgPrint(\"Daytime GMT (%u bytes): %s\\n\", Indicated, (char*)Data);
    return Indicated;
}

void CDaytimeSocket::On_connectComplete(PVOID, TDI_STATUS Status, uint)
{
    KeSetEvent(&event,IO_NO_INCREMENT, FALSE);


}
htg01
驱动牛犊
驱动牛犊
  • 注册日期2002-12-24
  • 最后登录2008-05-23
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2003-07-03 16:00
只要一加载这个Driver,就会打印出I am away这句,Socket已经断开。其中send成功,也受到回应,但是这后就断了。
游客

返回顶部