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


C++ NetClient类代码示例

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


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

示例1: NetClient

bool ServerConnectMgr::ConnectToServer(int32 nServerID,int32 nServerType,const char arrHost[32],int32 nPort,NetMsgEnter fEnter,NetMsgOn fMsg,NetMsgExit fExit)
{

	NetClientInfoVecterType::iterator it = m_vecNetClientInfo.begin();
	NetClientInfoVecterType::iterator itEnd = m_vecNetClientInfo.end();
	for (; it != itEnd;++it)
	{
		if((*it)->nServerID == nServerID)
			return false;
	}

	NetClient* pNetClient = new NetClient();
	pNetClient->SetAddress(arrHost, nPort);
	pNetClient->SetHandler(fEnter,fMsg,fExit);
	pNetClient->Start();

	NetClientInfo* pConn = new NetClientInfo();
	pConn->pNetClient = pNetClient;
	pConn->nServerID = nServerID;
	pConn->nServerType = nServerType;
	m_vecNetClientInfo.push_back(pConn);

	return true;

}
开发者ID:ACEZLY,项目名称:Dynet-Server,代码行数:25,代码来源:ServerConnectMgr.cpp

示例2: sendMatrix

void sendMatrix(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  NetClient *nc = GetNetClient(nrhs, prhs);

  if (nrhs != 2) mexErrMsgTxt("Two arguments required: handle, matrix.");
  unsigned long datalen = mxGetN(prhs[1]) * mxGetM(prhs[1]);
  switch(mxGetClassID(prhs[1])) {
  case mxINT8_CLASS:
  case mxUINT8_CLASS:
  case mxCHAR_CLASS: datalen *= sizeof(char); break;
  case mxINT16_CLASS:
  case mxUINT16_CLASS: datalen *= sizeof(short); break;
  case mxUINT32_CLASS:
  case mxINT32_CLASS: datalen *= sizeof(int); break;
  case mxDOUBLE_CLASS: datalen *= sizeof(double); break;
  case mxSINGLE_CLASS: datalen *= sizeof(float); break;
  default:
      mexErrMsgTxt("Argument 2 must be a matrix of numeric type.");
  }


  void *theMatrix = mxGetPr(prhs[1]);

  try {
      nc->sendData(theMatrix, datalen);
  } catch (const SocketException & e) {
      const std::string why (e.why());
      if (why.length()) mexWarnMsgTxt(why.c_str());
      RETURN_NULL();
  }

  RETURN(1);
}
开发者ID:cculianu,项目名称:StimulateOpenGL_II,代码行数:33,代码来源:CalinsNetMex.cpp

示例3: delete

void ServerConnectMgr::Update(int32 nSrvTime)
{
	// 检查要断开的NetClient
	DisconnectServerIDVectorType::iterator itServerID = m_vecNetClient.begin();
	DisconnectServerIDVectorType::iterator itEndServerID = m_vecNetClient.end();
	for (;itServerID != itEndServerID;++itServerID)
	{
		uint32 nServerID = *itServerID;
		for(NetClientInfoVecterType::iterator it = m_vecNetClientInfo.begin();it != m_vecNetClientInfo.end();)
		{
			if((*it)->nServerID == nServerID)
			{
				delete (*it)->pNetClient;
				(*it)->pNetClient = NULL;
				it = m_vecNetClientInfo.erase(it);
			}else
			{
				++it;
			}
		}
	}
	m_vecNetClient.clear();

	NetClientInfoVecterType::iterator it = m_vecNetClientInfo.begin();
	NetClientInfoVecterType::iterator itEnd = m_vecNetClientInfo.end();
	for(; it != itEnd; ++it)
	{
		NetClient* pNetClient = (*it)->pNetClient;
		if(pNetClient)
		{
			pNetClient->Update(nSrvTime);//1
		}
	}

}
开发者ID:ACEZLY,项目名称:Dynet-Server,代码行数:35,代码来源:ServerConnectMgr.cpp

示例4: query_series_instances

/*
 * query the number instances of a series
 */
int query_series_instances(const std::string& studyinstanceuid, const std::string& seriesinstanceuid, const std::string& server, const std::string& local_aet) {
	DcmDataset query;
	DcmElement* e = NULL;
	
	e = newDicomElement(DCM_QueryRetrieveLevel);
	e->putString("IMAGE");
	query.insert(e);

	e = newDicomElement(DCM_StudyInstanceUID);
	e->putString(studyinstanceuid.c_str());
	query.insert(e);

	e = newDicomElement(DCM_SeriesInstanceUID);
	e->putString(seriesinstanceuid.c_str());
	query.insert(e);

	e = newDicomElement(DCM_SOPInstanceUID);
	query.insert(e);

	e = newDicomElement(DCM_InstanceNumber);
	query.insert(e);

	std::cout << "NEW QUERY:" << std::endl;
	query.print(COUT);

	NetClient<FindAssociation> a;
	a.QueryServer(&query, server, local_aet, UID_FINDStudyRootQueryRetrieveInformationModel);

	DcmStack* result = a.GetResultStack();
	std::cout << "query_series_instances = " << result->card() << std::endl;
 
	return result->card();
}
开发者ID:Debian,项目名称:aeskulap,代码行数:36,代码来源:netquery.cpp

示例5: while

void OInputServer::sendToClients(char* event){
	// Iterate through all clients
	std::map<char*,NetClient*>::iterator itr = netClients.begin();
	while( itr != netClients.end() ){
		NetClient* client = itr->second;
		client->sendEvent( event );
		itr++;
	}// while
	delete[] event; // Clean up event after being set to all clients
}// createClient
开发者ID:uic-evl,项目名称:omicron,代码行数:10,代码来源:legacy-oinputserver.cpp

示例6: while

int NetClient::syncSender (void* instance){ /** OPCIONAL **/
	NetClient* pNetClient = (NetClient *) instance;

	while (!pNetClient->m_stopClient){
		SDL_Delay(NetControl::M_SYNC_SEND_PERIOD);
		pNetClient->asyncSend();
	}
	
	pNetClient->m_syncSenderIsOn = false;
	
	return 0;
}
开发者ID:indigente,项目名称:libinge,代码行数:12,代码来源:NetClient.cpp

示例7: readString

void readString(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  if(nlhs < 1) mexErrMsgTxt("One output argument required.");
  NetClient *nc = GetNetClient(nrhs, prhs);

  try {
    std::string theString ( nc->receiveString() );
    plhs[0] = mxCreateString(theString.c_str());
  } catch (const SocketException & e) {
    mexWarnMsgTxt(e.why().c_str());
    RETURN_NULL(); // note empty return..
  }
}
开发者ID:AndrewHires,项目名称:Solo,代码行数:13,代码来源:FSMClient.cpp

示例8: doA

static void
doA()
{
  cout << "[A] Initialized." << endl;

  NetClient* net = new MPIClient(0);
  mpz_t a;
  mpz_init_set_si(a, rand() + 213);

  cout << "[A] Send " << 1 << " mpz_t to A" << endl;
  gmp_printf("[A] Should expect: %Zd\n", a);
  net->sendZVector("Vec from A.", &a, 1);

  string header;
  header = net->waitForMessage();
  int valid = net->getDataAsZVector(&a, 1);
  cout << "[A] Recv " << valid << " mpz_t from B with the header: '" << header << "'" << endl;
  gmp_printf("[A] We got: %Zd\n", a);

  cout << "[A] Sending empty message." << endl;
  net->sendEmpty("Empty message from A.");

  header = "MSG 1";
  cout << "[A] Sending message: '" << header << "'." << endl;
  net->sendData(header, header.c_str(), header.length());

  header = "MSG 2";
  cout << "[A] Sending message: '" << header << "'." << endl;
  net->sendData(header, header.c_str(), header.length());

  cout << net->getGlobalStat() << endl;

  delete net;
}
开发者ID:fsq120,项目名称:ginger-zaatar-allspice,代码行数:34,代码来源:mpinet_test.cpp

示例9: onDisconnect

void SMWServer::onDisconnect(NetClient& client)
{
    printf("Disconnect event [%lu].\n", client.getPlayerID());
    uint64_t playerID = client.getPlayerID();
    if (players.count(playerID)) {
        playerLeavesRoom(playerID);
        log("[info] %[email protected]%s disconnected.",
            players[playerID].name.c_str(),
            players[playerID].network_client->addressAsString().c_str());
        players.erase(playerID);
    }
    else
        printf("No such player!\n");
}
开发者ID:Fordi,项目名称:supermariowar,代码行数:14,代码来源:server.cpp

示例10: query_series_from_net

void query_series_from_net(const std::string& studyinstanceuid, const std::string& server, const std::string& local_aet, const sigc::slot< void, const Glib::RefPtr< ImagePool::Series >& >& resultslot) {
	DcmDataset query;
	DcmElement* e = NULL;
	
	e = newDicomElement(DCM_QueryRetrieveLevel);
	e->putString("SERIES");
	query.insert(e);

	e = newDicomElement(DCM_SpecificCharacterSet);
	query.insert(e);

	e = newDicomElement(DCM_StudyInstanceUID);
	e->putString(studyinstanceuid.c_str());
	query.insert(e);

	e = newDicomElement(DCM_SeriesInstanceUID);
	query.insert(e);

	e = newDicomElement(DCM_SeriesNumber);
	query.insert(e);

	e = newDicomElement(DCM_Modality);
	query.insert(e);

	e = newDicomElement(DCM_SeriesDescription);
	query.insert(e);

	e = newDicomElement(DCM_SeriesTime);
	query.insert(e);

	e = newDicomElement(DCM_StationName);
	query.insert(e);

	e = newDicomElement(DCM_NumberOfSeriesRelatedInstances);
	query.insert(e);


	std::cout << "NEW QUERY:" << std::endl;
	query.print(COUT);

	NetClient<FindAssociation> a;
	a.QueryServer(&query, server, local_aet, UID_FINDStudyRootQueryRetrieveInformationModel);

	DcmStack* result = a.GetResultStack();
	for(unsigned int i=0; i<result->card(); i++) {
		DcmDataset* dset = (DcmDataset*)result->elem(i);
		dset->print(COUT);
		resultslot(create_query_series(dset));
	}
}
开发者ID:Debian,项目名称:aeskulap,代码行数:50,代码来源:netquery.cpp

示例11: st_WaitEeventThreadProc

static void* st_WaitEeventThreadProc(void* lpParam)
{
	NetClient* pClientThis = (NetClient*)lpParam;
	int sockeId = pClientThis->GetSockId();
	std::string recvStr;
	while (!pClientThis->GetShutDown())
	{
		recvStr.clear();
		fu_socket_recv(sockeId, recvStr);
		if (!recvStr.empty())
		{
			pClientThis->NotifyRecvText(recvStr.c_str(), recvStr.length());
		}
	}
	return 0;
}
开发者ID:teahouse,项目名称:fuserver,代码行数:16,代码来源:NetClient.cpp

示例12: readLines

void readLines(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  if(nlhs < 1) mexErrMsgTxt("One output argument required.");

  NetClient *nc = GetNetClient(nrhs, prhs);
  try {
    char **lines = nc->receiveLines();
    int m;
    for (m = 0; lines[m]; m++) {} // count number of lines
    plhs[0] = mxCreateCharMatrixFromStrings(m, const_cast<const char **>(lines));
    NetClient::deleteReceivedLines(lines);
  } catch (const SocketException &e) {
    mexWarnMsgTxt(e.why().c_str());
    RETURN_NULL(); // empty return set
  }
}
开发者ID:AndrewHires,项目名称:Solo,代码行数:16,代码来源:FSMClient.cpp

示例13: createNewClient

void createNewClient(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  if (nlhs != 1) mexErrMsgTxt("Cannot create a client since no output (lhs) arguments were specified!");
  if (nrhs != 2) mexErrMsgTxt("Need two input arguments: Host, port!");
  const mxArray *host = prhs[0], *port = prhs[1];
  if ( !mxIsChar(host) || mxGetM(host) != 1 ) mexErrMsgTxt("Hostname must be a string row vector!");
  if ( !mxIsDouble(port) || mxGetM(port) != 1 || mxGetN(port) != 1) mexErrMsgTxt("Port must be a single numeric value.");
  
  char *hostStr = mxArrayToString(host);
  unsigned short portNum = static_cast<unsigned short>(*mxGetPr(port));
  NetClient *nc = new NetClient(hostStr, portNum);
  mxFree(hostStr);
  nc->setSocketOption(Socket::TCPNoDelay, true);
  int h = handleId++;
  MapPut(h, nc);
  RETURN(h);
}
开发者ID:AndrewHires,项目名称:Solo,代码行数:17,代码来源:FSMClient.cpp

示例14: query_study_series

/*
 * query all seriesinstanceuid's and the number series of a study
 */
int query_study_series(const std::string& studyinstanceuid, const std::string& server, const std::string& local_aet, std::list<std::string>& seriesinstanceuids) {
	DcmDataset query;
	DcmElement* e = NULL;
	
	e = newDicomElement(DCM_QueryRetrieveLevel);
	e->putString("SERIES");
	query.insert(e);

	e = newDicomElement(DCM_StudyInstanceUID);
	e->putString(studyinstanceuid.c_str());
	query.insert(e);

	e = newDicomElement(DCM_SeriesInstanceUID);
	query.insert(e);

	e = newDicomElement(DCM_SeriesNumber);
	query.insert(e);

	e = newDicomElement(DCM_Modality);
	query.insert(e);

	std::cout << "NEW QUERY:" << std::endl;
	query.print(COUT);

	NetClient<FindAssociation> a;
	a.QueryServer(&query, server, local_aet, UID_FINDStudyRootQueryRetrieveInformationModel);

	DcmStack* result = a.GetResultStack();
	DcmDataset* dset;
	OFString ofstr;

	seriesinstanceuids.clear();
	for(int i = 0; i < result->card(); i++) {
		dset = (DcmDataset*)result->elem(i);
		if(dset->findAndGetOFString(DCM_SeriesInstanceUID, ofstr).good()) {
			seriesinstanceuids.push_back(ofstr.c_str());
		}
	}

	std::cout << result->card() << " Responses" << std::endl;
	int count = result->card();

	return count;
}
开发者ID:Debian,项目名称:aeskulap,代码行数:47,代码来源:netquery.cpp

示例15: tryConnection

void tryConnection(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
  NetClient *nc = GetNetClient(nrhs, prhs);
  //if(nlhs < 1) mexErrMsgTxt("One output argument required.");
  bool ok = false;
  try {
    ok = nc->connect();
  } catch (const SocketException & e) {
    mexWarnMsgTxt(e.why().c_str());
    RETURN_NULL();
  }

  if (!ok) {
    mexWarnMsgTxt(nc->errorReason().c_str());
    RETURN_NULL();
  }

  RETURN(1);
}
开发者ID:AndrewHires,项目名称:Solo,代码行数:19,代码来源:FSMClient.cpp


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