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


C++ SocketEndpoint类代码示例

本文整理汇总了C++中SocketEndpoint的典型用法代码示例。如果您正苦于以下问题:C++ SocketEndpoint类的具体用法?C++ SocketEndpoint怎么用?C++ SocketEndpoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: sizeof

  TcpClient* TcpServer::Accept()
  {
    if (m_listenSocket != INVALID_SOCKET)
    {
      char sockAddrData[sizeof(sockaddr_in6)] = { 0 };
      int sockAddrData_Size = sizeof(sockAddrData);
      SOCKET remoteSocket = accept(m_listenSocket, reinterpret_cast<sockaddr*>(sockAddrData), &sockAddrData_Size);
      
      if (remoteSocket != INVALID_SOCKET)
      {
        SocketEndpoint clientEndpoint;
        switch (m_localEndpoint.GetAddressFamily())
        {
        case AF_INET:
          clientEndpoint.Set(*reinterpret_cast<sockaddr_in*>(sockAddrData));
          break;
        case AF_INET6:
          clientEndpoint.Set(*reinterpret_cast<sockaddr_in6*>(sockAddrData));
          break;
        }

        return new TcpClient(remoteSocket, clientEndpoint);
      }
    }

    return nullptr;
  }
开发者ID:woegster,项目名称:Schublade,代码行数:27,代码来源:TcpServer.cpp

示例2: runLocalDaFileSvr

bool CDfuPlusHelper::runLocalDaFileSvr(SocketEndpoint &listenep,bool requireauthenticate, unsigned timeout)
{
    Owned<CDafsThread> thr = new CDafsThread(listenep,requireauthenticate); 
    if (!thr->ok())
        return false;
    thr->start();
    StringBuffer eps;
    if (listenep.isNull())
        progress("Started local Dali file server on port %d\n", listenep.port?listenep.port:DAFILESRV_PORT);
    else
        progress("Started local Dali file server on %s\n", listenep.getUrlStr(eps).str());
    if (timeout==0) {
        setDafsTrace(NULL,0); // disable client tracing
        dafsthread.setown(thr.getClear());
    }
    else {
        loop {
            Sleep(500);
            if (thr->idleTime()>timeout) { 
                thr->stop();
                break;
            }
        }
    }
    return true;
}
开发者ID:EwokVillage,项目名称:HPCC-Platform,代码行数:26,代码来源:dfuplus.cpp

示例3: nextSmartEndpoint

ISmartSocket *CSmartSocketFactory::connect_timeout( unsigned timeoutms)
{
    SmartSocketEndpoint *ss = nextSmartEndpoint();
    if (!ss)
        throw createSmartSocketException(0, "smartsocket failed to get nextEndpoint");

    ISocket *sock = NULL;
    SocketEndpoint ep;
    try 
    {
        {
            synchronized block(lock);
            ss->checkHost(dnsInterval);
            ep = ss->ep;
        }
        if (timeoutms)
            sock = ISocket::connect_timeout(ep, timeoutms);
        else
            sock = ISocket::connect(ep);

        return new CSmartSocket(sock, ep, this);
    }
    catch (IException *e)
    {
        StringBuffer s("CSmartSocketFactory::connect ");
        ep.getUrlStr(s);
        EXCLOG(e,s.str());
        ss->status=false;
        if (sock)
            sock->Release();
        throw;
    }
}
开发者ID:RogerDev,项目名称:HPCC-Platform,代码行数:33,代码来源:jsmartsock.cpp

示例4: main

 virtual void main()
 {
     running = true;
     loop
     {
         INode *senderNode;
         CMessageBuffer msg;
         if (!queryWorldCommunicator().recv(msg, NULL, MPTAG_THORREGISTRATION, &senderNode))
             return;
         rank_t sender = queryNodeGroup().rank(senderNode);
         SocketEndpoint ep = senderNode->endpoint();
         StringBuffer url;
         ep.getUrlStr(url);
         if (RANK_NULL == sender)
         {
             PROGLOG("Node %s trying to deregister is not part of this cluster", url.str());
             continue;
         }
         RegistryCode code;
         msg.read((int &)code);
         if (rc_deregister != code)
             throwUnexpected();
         Owned<IException> e = deserializeException(msg);
         if (e.get())
             EXCLOG(e, "Slave unregistered with exception");
         registry.deregisterNode(sender-1);
     }
     running = false;
 }
开发者ID:hhy5277,项目名称:HPCC-Platform,代码行数:29,代码来源:thmastermain.cpp

示例5: replyError

static void replyError(unsigned errorCode, const char *errorMsg)
{
    SocketEndpoint myEp = queryMyNode()->endpoint();
    StringBuffer str("Node '");
    myEp.getUrlStr(str);
    str.append("' exception: ").append(errorMsg);
    Owned<IException> e = MakeStringException(errorCode, "%s", str.str());
    CMessageBuffer msg;
    serializeException(e, msg);
    queryWorldCommunicator().send(msg, 0, MPTAG_THORREGISTRATION);
}
开发者ID:sukhong,项目名称:HPCC-Platform,代码行数:11,代码来源:thslavemain.cpp

示例6: CDafsThread

 CDafsThread(SocketEndpoint &_listenep,bool requireauthenticate) 
     : listenep(_listenep)
 {
     if (listenep.port==0)
         listenep.port = DAFILESRV_PORT;
     StringBuffer eps;
     if (listenep.isNull())
         eps.append(listenep.port);
     else
         listenep.getUrlStr(eps);
     enableDafsAuthentication(requireauthenticate);
     server.setown(createRemoteFileServer());
 }
开发者ID:EwokVillage,项目名称:HPCC-Platform,代码行数:13,代码来源:dfuplus.cpp

示例7: preStart

 virtual void preStart(size32_t parentExtractSz, const byte *parentExtract)
 {
     CMasterActivity::preStart(parentExtractSz, parentExtract);
     ActPrintLog("preStart");
     imaster = CreateThorSorterMaster(this);
     unsigned s=0;
     for (; s<container.queryJob().querySlaves(); s++)
     {
         SocketEndpoint ep;
         ep.deserialize(queryInitializationData(s)); // this is a bit of a Kludge until we get proper MP Thor
         imaster->AddSlave(&container.queryJob().queryJobComm(), s+1, ep,mpTagRPC);
     }
 }
开发者ID:hszander,项目名称:HPCC-Platform,代码行数:13,代码来源:thmsort.cpp

示例8: checkLocalDaFileSvr

bool CDfuPlusHelper::checkLocalDaFileSvr(const char *eps,SocketEndpoint &epout)
{
    if (!eps||!*eps)
        epout.setLocalHost(DAFILESRV_PORT);
    else {
        epout.set(eps,DAFILESRV_PORT);
        if (!epout.isLocal())
            return false;
    }
    progress("Checking for local Dali File Server\n");
    if (!testDaliServixPresent(epout)) // only lookup local
        runLocalDaFileSvr(epout,false,0);
    return true;
}
开发者ID:EwokVillage,项目名称:HPCC-Platform,代码行数:14,代码来源:dfuplus.cpp

示例9: updateDaliEnv

bool updateDaliEnv(IPropertyTree *env, bool forceGroupUpdate, const char *daliIp)
{
    Owned<IPropertyTreeIterator> dalis = env->getElements("Software/DaliServerProcess/Instance");
    if (!dalis||!dalis->first()) {
        fprintf(stderr,"Could not find DaliServerProcess\n");
        return false;
    }
    SocketEndpoint daliep;
    loop {
        const char *ps = dalis->get().queryProp("@port");
        unsigned port = ps?atoi(ps):0;
        if (!port)
            port = DALI_SERVER_PORT;
        daliep.set(dalis->get().queryProp("@netAddress"),port);
        if (daliIp && *daliIp) {
            SocketEndpoint testep;
            testep.set(daliIp,DALI_SERVER_PORT);
            if (testep.equals(daliep))
                break;
            daliep.set(NULL,0);
        }
        if (!dalis->next())
            break;
        if (!daliep.isNull()) {
            fprintf(stderr,"Ambiguous DaliServerProcess instance\n");
            return false;
        }
    }
    if (daliep.isNull()) {
        fprintf(stderr,"Could not find DaliServerProcess instance\n");
        return false;
    }
    SocketEndpointArray epa;
    epa.append(daliep);
    Owned<IGroup> group = createIGroup(epa);

    bool ret = true;
    initClientProcess(group, DCR_Util);
    StringBuffer response;
    if (querySDS().updateEnvironment(env, forceGroupUpdate, response))
    {
        StringBuffer tmp;
        PROGLOG("Environment and node groups updated in dali at %s",daliep.getUrlStr(tmp).str());
    }
    else
        ret = false;
    if (response.length())
        WARNLOG("%s", response.str());

    closedownClientProcess();
    return ret;
}
开发者ID:aa0,项目名称:HPCC-Platform,代码行数:52,代码来源:daclient.cpp

示例10: SetServerAddr

 void SetServerAddr(SocketEndpoint &endpoint)
 {
     free(hostname);
     StringBuffer ipname;
     endpoint.getIpText(ipname);
     hostname = strdup(ipname.str());
     hostport = endpoint.port;
 }
开发者ID:AttilaVamos,项目名称:HPCC-Platform,代码行数:8,代码来源:hrpcsock.cpp

示例11: Start

  bool TcpServer::Start(const SocketEndpoint& localEndpoint, int Backlog)
  {
    if (m_listenSocket == INVALID_SOCKET)
    {
      m_listenSocket = socket(localEndpoint.GetAddressFamily(), SOCK_STREAM, IPPROTO_TCP);
      if (m_listenSocket != INVALID_SOCKET)
      {
        if (bind(m_listenSocket, localEndpoint.GetIpGeneric(), static_cast<int>(localEndpoint.GetGenericIpSize())) == 0)
        {
          if (listen(m_listenSocket, Backlog) == 0)
          {
            m_localEndpoint = localEndpoint;
            return true;
          }            
        }

        CleanUp();
      }
    }

    return false;
  }
开发者ID:woegster,项目名称:Schublade,代码行数:22,代码来源:TcpServer.cpp

示例12: init

// IThorSlaveActivity
    virtual void init(MemoryBuffer & data, MemoryBuffer &slaveData)
    {       
        appendOutputLinked(this);
        if(!isLocal) {
            mpTagRPC = container.queryJob().deserializeMPTag(data);
            mptag_t barrierTag = container.queryJob().deserializeMPTag(data);
            barrier.setown(container.queryJob().createBarrier(barrierTag));
            portbase = allocPort(NUMSLAVEPORTS);
            SocketEndpoint server;
            server.setLocalHost(portbase);
            sorter.setown(CreateThorSorter(this, server,&container.queryJob().queryIDiskUsage(),&container.queryJob().queryJobComm(),mpTagRPC));
            server.serialize(slaveData);
        }
        helper = static_cast <IHThorJoinArg *> (queryHelper());
        compare = helper->queryCompareLeft();                   // NB not CompareLeftRight
        keyserializer = helper->querySerializeLeft();           // hopefully never need right
        if(isLightweight) 
            ActPrintLog("SELFJOIN: LIGHTWEIGHT");
        else if(isLocal) 
            ActPrintLog("SELFJOIN: LOCAL");
        else
            ActPrintLog("SELFJOIN: GLOBAL");
    }
开发者ID:hszander,项目名称:HPCC-Platform,代码行数:24,代码来源:thselfjoinslave.cpp

示例13: toEp

void toEp(SocketEndpoint & ep, LPCSTR epTxt)
{
    char * tmp = static_cast <char *> (alloca(strlen(epTxt) + 1));
    strcpy(tmp, epTxt);
    for(int i = strlen(tmp); i >= 0; i--)
    {
        if(*(tmp + i) == ':')
        {
            ep.port = atoi(tmp + i + 1);
            *(tmp + i) = 0;
            ep.ipset(tmp);
            break;
        }
    }
}
开发者ID:Goon83,项目名称:HPCC-Platform,代码行数:15,代码来源:util.cpp

示例14: CMergeReadStream

    CMergeReadStream(IRowInterfaces *rowif, unsigned streamno,SocketEndpoint &targetep, rowcount_t startrec, rowcount_t numrecs)
    {
        endpoint = targetep;
#ifdef _TRACE
        char url[100];
        targetep.getUrlStr(url,sizeof(url));
        PrintLog("SORT Merge READ: Stream(%u) %s, pos=%" RCPF "d len=%" RCPF "u",streamno,url,startrec,numrecs);
#endif
        SocketEndpoint mergeep = targetep;
        mergeep.port+=SOCKETSERVERINC; 
        stream = ConnectMergeRead(streamno,rowif,mergeep,startrec,numrecs);
#ifdef _TRACE
        PrintLog("SORT Merge READ: Stream(%u) connected to %s",streamno,url);
#endif
    }
开发者ID:RobertoMalatesta,项目名称:HPCC-Platform,代码行数:15,代码来源:tsorts1.cpp

示例15: UnregisterSelf

bool UnregisterSelf(IException *e)
{
    if (!hasMPServerStarted())
        return false;

    StringBuffer slfStr;
    slfEp.getUrlStr(slfStr);
    LOG(MCdebugProgress, thorJob, "Unregistering slave : %s", slfStr.str());
    try
    {
        CMessageBuffer msg;
        msg.append((int)rc_deregister);
        serializeException(e, msg); // NB: allows exception to be NULL
        if (!queryWorldCommunicator().send(msg, masterNode, MPTAG_THORREGISTRATION, 60*1000))
        {
            LOG(MCerror, thorJob, "Failed to unregister slave : %s", slfStr.str());
            return false;
        }
        LOG(MCdebugProgress, thorJob, "Unregistered slave : %s", slfStr.str());
        return true;
    }
    catch (IException *e) {
        if (!jobListenerStopped)
            FLLOG(MCexception(e), thorJob, e,"slave unregistration error");
        e->Release();
    }
    return false;
}
开发者ID:sukhong,项目名称:HPCC-Platform,代码行数:28,代码来源:thslavemain.cpp


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