当前位置: 首页>>代码示例>>C++>>正文


C++ TCPSocket::GetRemoteAddrStr方法代码示例

本文整理汇总了C++中TCPSocket::GetRemoteAddrStr方法的典型用法代码示例。如果您正苦于以下问题:C++ TCPSocket::GetRemoteAddrStr方法的具体用法?C++ TCPSocket::GetRemoteAddrStr怎么用?C++ TCPSocket::GetRemoteAddrStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TCPSocket的用法示例。


在下文中一共展示了TCPSocket::GetRemoteAddrStr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetSessionTask

Task* CRTConnListener::GetSessionTask(int osSocket, struct sockaddr_in* addr)
{
    TCPSocket* theSocket = NULL;
    Assert(osSocket != EventContext::kInvalidFileDesc);

    // when the server is behing a round robin DNS, the client needs to knwo the IP address ot the server
    // so that it can direct the "POST" half of the connection to the same machine when tunnelling RTSP thru HTTP

    CRTConnection* theTask = new CRTConnection();
    if(NULL == theTask)
        return NULL;
    theSocket = theTask->GetSocket();  // out socket is not attached to a unix socket yet.

    //set options on the socket
    int sndBufSize = 96L * 1024L;
    theSocket->Set(osSocket, addr);
    theSocket->InitNonBlocking(osSocket);
    //we are a server, always disable nagle algorithm
    theSocket->NoDelay();
    theSocket->KeepAlive();
    theSocket->SetSocketBufSize(sndBufSize);
    //setup the socket. When there is data on the socket,
    //theTask will get an kReadEvent event
    theSocket->RequestEvent(EV_RE);
    theTask->SetTimer(30*1000);

    StrPtrLen* remoteStr = theSocket->GetRemoteAddrStr();
    LI("CRTConnListener Get a connection,ip:%.*s port:%d \n",remoteStr->Len, remoteStr->Ptr, ntohs(addr->sin_port));

    this->RunNormal();

    return theTask;
}
开发者ID:BoYuanZjq,项目名称:Teameeting-MsgServer,代码行数:33,代码来源:CRTConnListener.cpp


注:本文中的TCPSocket::GetRemoteAddrStr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。