• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ network类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: connect

void connect(handshake& shake, network& net,
    const std::string& hostname, uint16_t port,
    network::connect_handler handle_connect)
{
    net.connect(hostname, port,
        std::bind(finish_connect, _1, _2, std::ref(shake), handle_connect));
}
开发者ID:Mrkebubun,项目名称:libbitcoin,代码行数:7,代码来源:handshake.cpp


示例2: push

//============================================================================
double push(network net, shared_ptr<vector<sample>> dataSet)
{
    vector<double> input;
    vector<double> expected;
    vector<double> actual;
    double correct = 0;
    int i = 0;
    vector<sample>::iterator currentSample = dataSet->begin();
    //network dnet(data.getTableName(), data.getAttributeCount(), data.getCatagoryCount(), HIDDEN_LAYERS, LAYER_SIZE);
    while(currentSample != dataSet->end()){
        //currentSample->printSample();
        input = currentSample->getValues();
        expected = m_typeToVector[currentSample->getClassification()];
        actual = net.push(input);
        if (m_data.classVector(m_data.getCatagoryCount(), catagorize(actual)) == expected) correct++;
        if (i % 10 == 0 && !m_quiet) {
            cout << "Actual = ";
            printVector(actual);
            cout << " ";
            cout << "Expected = ";
            printVector(expected);
            if (m_data.classVector(m_data.getCatagoryCount(), catagorize(actual)) != expected){
                cout << " x";
            }
            cout << endl;
        }
        i++;
        currentSample++;
    }
    double total = m_data.getSampleCount();
    double percent = (correct / total) * 100;
    cout << correct << "/" << total << " = " << percent << "% correct." << endl;
    return percent;
}
开发者ID:mkknts35,项目名称:ANN,代码行数:35,代码来源:ann.cpp


示例3: scan_Worker

void scan_Worker(network net, bool increment = false)
{
    int count = 1;
    if(increment) // work upwards
    {
        addr next = net.increment_naddr(count);
        while(next != net.get_baddr() && pings.find(next) == pings.end())
        {
            if(sys_ping(next))
            {
                ping_mutex.lock();
                pings[next] = increment;
                ping_mutex.unlock();
            }
            count++;
            next = net.increment_naddr(count);
        }
        return;
    }

    addr prev = net.decrement_baddr(count);
    // workers haven't met in the middle and next isn't broadcast
    while(prev != net.get_naddr() && pings.find(prev) == pings.end())
    {
        if(sys_ping(prev))
        {
            ping_mutex.lock();
            pings[prev] = increment;
            ping_mutex.unlock();
        }
        count++;
        prev = net.decrement_baddr(count);
    }
    return;
}
开发者ID:mg5050,项目名称:net_scan,代码行数:35,代码来源:pinger.cpp


示例4: train

//============================================================================
void train(network net, shared_ptr<vector<sample>> dataSet)
{
    vector<double> input;
    vector<double> expected;
    vector<double> actual;
    vector<sample>::iterator currentSample = dataSet->begin();
#if WINDOWSSYSTEM
	FILETIME tStart, tEnd;
	GetSystemTimeAsFileTime(&tStart);
#else
	struct timeval profileStart, profileEnd;
	gettimeofday(&profileStart, NULL);
#endif
    int p = 0, oldp = -1;
    int iterations = m_data.getSampleCount() * ITERATIONS;
    outputStatusMessage("Training the network");

    for (unsigned int g = 0; g < ITERATIONS; g++) {
        p = calcPercentageComplete(g, ITERATIONS);
        if (oldp < p) {
            oldp = updateOutputPercentage(p, false);
        }
        currentSample = dataSet->begin();
        while(currentSample != dataSet->end()){
            input = currentSample->getValues();
            expected = m_typeToVector[currentSample->getClassification()];
            actual = net.push(input);
            net.train(input, expected);
            currentSample++;
        }
    }
    updateOutputPercentage(p, true);
#if WINDOWSSYSTEM
	GetSystemTimeAsFileTime(&tEnd);
	PrintTimeDifference(tStart, tEnd);
#else
	gettimeofday(&profileEnd, NULL);
	PrintTimeDifference(profileStart, profileEnd);
#endif
}
开发者ID:mkknts35,项目名称:ANN,代码行数:41,代码来源:ann.cpp


示例5: print_output

  void print_output(network & net){
    int i, size;
    std::vector<float> output;

    output = net.output();
    size = output.size();
    std::cout<<"[";
    for(i=0; i<size-1; i++)
      std::cout<<output[i]<<" ";
    if(i<size)
      std::cout<<output[i];
    std::cout<<"]"<<std::endl;
  }
开发者ID:shinhermit,项目名称:neural_network,代码行数:13,代码来源:funcs.cpp


示例6: main

int main(int argc, char** argv) {
	char input = 0;
	timer ter;
	cout << "Hello! This is a GameFramework application." << endl;
	cout << "Press q to quit, press s to Start Server." << endl;	
	
	while(1) {
		cin >> input;
		if(input == 's') {
			global_network.listen_thread();
		} else if(input == 'q') {
			break;
		} else if(input != '\n') {
			cout << "Unknown command '" << input << "'! Ignoring...\n";
		}
	}
	cout << ter.elapsed()<<"s passed."<<endl;
	return 0;
}
开发者ID:V-ea,项目名称:GameFramework,代码行数:19,代码来源:main.cpp


示例7: pp

std::string pp(const network& x)
{
  std::stringstream s;
  x.write(s);
  return s.str();
}
开发者ID:gijskant,项目名称:mcrl2-pmc,代码行数:6,代码来源:network.cpp


示例8: main

int main(int argc, char *argv[])
{	
	//--------------------------------------------------------------------//
	//------------------------- SETUP REQUIRED NODES ---------------------//
	//--------------------------------------------------------------------//
	
	// Setup the command line parameters.
	setupParams(argc, argv);
	
	// Setup all the sockets.
	setupSockets();
    
	// Setup the capture socket server for Mac.
	#if (XN_PLATFORM == XN_PLATFORM_MACOSX)
		if(_featureDepthMapCapture || _featureRGBCapture)
		{
			if(_useSockets)
			{
				g_AS3Network = network();
				g_AS3Network.init(setupServer);
			}
		}
	#endif
	
	// Setup the status.
    XnStatus _status = XN_STATUS_OK;
    EnumerationErrors _errors;
    
    // Context Init and Add license.
	_status = _context.Init();
	CHECK_RC(_status, "AS3OpenNI :: Initialize context");
	_context.SetGlobalMirror(_mirror);
	
	XnChar vendor[XN_MAX_NAME_LENGTH];
	XnChar license[XN_MAX_LICENSE_LENGTH];

	_license.strVendor[XN_MAX_NAME_LENGTH] = strcmp(vendor, "PrimeSense");
	_license.strKey[XN_MAX_LICENSE_LENGTH] = strcmp(license, "0KOIk2JeIBYClPWVnMoRKn5cdY4=");
		
	_status = _context.AddLicense(_license);
   	CHECK_RC(_status, "AS3OpenNI :: Added license");
   	
   	// Set it to VGA maps at 30 FPS
	_depthMode.nXRes = 640;
	_depthMode.nYRes = 480;
	_depthMode.nFPS = 30;
	
	// Depth map create.
	_status = _depth.Create(_context);
	CHECK_RC(_status, "AS3OpenNI :: Create depth generator");
	_status = _depth.SetMapOutputMode(_depthMode);
	
	// Depth map create.
	_status = _image.Create(_context);
	CHECK_RC(_status, "AS3OpenNI :: Create image generator");
	_status = _image.SetMapOutputMode(_depthMode);
	_status = _image.SetPixelFormat(XN_PIXEL_FORMAT_RGB24);
	
	// Create the hands generator.
	_status = _hands.Create(_context);
	CHECK_RC(_status, "AS3OpenNI :: Create hands generator");
	_hands.SetSmoothing(0.1);

	// Create the gesture generator.
	_status = _gesture.Create(_context);
	CHECK_RC(_status, "AS3OpenNI :: Create gesture generator");
	
	// Create user generator.
	_status = _userGenerator.Create(_context);
	CHECK_RC(_status, "AS3OpenNI :: Find user generator");
	
	// Create and initialize point tracker
	_sessionManager = new XnVSessionManager();
	_status = _sessionManager->Initialize(&_context, "Wave", "RaiseHand");
	
	if (_status != XN_STATUS_OK)
	{
		printf("AS3OpenNI :: Couldn't initialize the Session Manager: %s\n", xnGetStatusString(_status));
		CleanupExit();
	}
	_sessionManager->RegisterSession(NULL, &SessionStart, &SessionEnd, &SessionProgress);
	
	// Start catching signals for quit indications
	CatchSignals(&_quit);
	
	//---------------------------------------------------------------//
	//------------------------- SETUP FEATURES ---------------------//
	//--------------------------------------------------------------//
	
	// Define the Wave and SinglePoint detectors.
	_waveDetector = new XnVWaveDetector();
	
	// SinglePoint detector.
	if(_featureSinglePoint) _waveDetector->RegisterPointUpdate(NULL, &OnPointUpdate);
	
	// Feature Gesture.
	if(_featureGesture)
	{
		// Wave detector.
		_waveDetector->RegisterWave(NULL, &OnWave);
//.........这里部分代码省略.........
开发者ID:alfiandosengkey,项目名称:as3openni,代码行数:101,代码来源:main.cpp


示例9: easy_eval

double easy_eval(const tavla& t, const network& net, int turn) {
	double input[198];
	t.to_vector(input, turn);
	return net.evaluate(input);
}
开发者ID:hbirler,项目名称:backgammoncpp,代码行数:5,代码来源:main.cpp


示例10: Socket

// Ensure that a certificate that WAS generated using the certificate
// authority is NOT allowed to communicate when the SSL_REQUIRE_CERT
// flag is enabled.
TEST_F(SSLTest, RequireCertificate)
{
  Try<Socket> server = setup_server({
      {"SSL_ENABLED", "true"},
      {"SSL_KEY_FILE", key_path().value},
      {"SSL_CERT_FILE", certificate_path().value},
      {"SSL_REQUIRE_CERT", "true"}});
  ASSERT_SOME(server);

  Try<Subprocess> client = launch_client({
      {"SSL_ENABLED", "true"},
      {"SSL_KEY_FILE", key_path().value},
      {"SSL_CERT_FILE", certificate_path().value},
      {"SSL_REQUIRE_CERT", "true"}},
      server.get(),
      true);
  ASSERT_SOME(client);

  Future<Socket> socket = server.get().accept();
  AWAIT_ASSERT_READY(socket);

  // TODO(jmlvanre): Remove const copy.
  AWAIT_ASSERT_EQ(data, Socket(socket.get()).recv());
  AWAIT_ASSERT_READY(Socket(socket.get()).send(data));

  AWAIT_ASSERT_READY(await_subprocess(client.get(), 0));
}
开发者ID:fin09pcap,项目名称:mesos,代码行数:30,代码来源:ssl_tests.cpp


示例11: Socket

// Ensure that a certificate that was not generated using the
// certificate authority is still allowed to communicate as long as
// the LIBPROCESS_SSL_VERIFY_CERT and LIBPROCESS_SSL_REQUIRE_CERT
// flags are disabled.
TEST_F(SSLTest, NoVerifyBadCA)
{
  Try<Socket> server = setup_server({
      {"LIBPROCESS_SSL_ENABLED", "true"},
      {"LIBPROCESS_SSL_KEY_FILE", key_path().string()},
      {"LIBPROCESS_SSL_CERT_FILE", certificate_path().string()},
      {"LIBPROCESS_SSL_VERIFY_CERT", "false"},
      {"LIBPROCESS_SSL_REQUIRE_CERT", "false"}});
  ASSERT_SOME(server);

  Try<Subprocess> client = launch_client({
      {"LIBPROCESS_SSL_ENABLED", "true"},
      {"LIBPROCESS_SSL_KEY_FILE", scrap_key_path().string()},
      {"LIBPROCESS_SSL_CERT_FILE", scrap_certificate_path().string()},
      {"LIBPROCESS_SSL_REQUIRE_CERT", "true"},
      {"LIBPROCESS_SSL_CA_FILE", certificate_path().string()}},
      server.get(),
      true);
  ASSERT_SOME(client);

  Future<Socket> socket = server.get().accept();
  AWAIT_ASSERT_READY(socket);

  // TODO(jmlvanre): Remove const copy.
  AWAIT_ASSERT_EQ(data, Socket(socket.get()).recv());
  AWAIT_ASSERT_READY(Socket(socket.get()).send(data));

  AWAIT_ASSERT_READY(await_subprocess(client.get(), 0));
}
开发者ID:SStar1314,项目名称:mesos,代码行数:33,代码来源:ssl_tests.cpp


示例12:

TEST_F(SSLClientTest, client)
{
  // Create the socket based on the 'use_ssl' flag. We use this to
  // test whether a regular socket could connect to an SSL server
  // socket.
  const Try<Socket> create =
    Socket::create(flags.use_ssl ? Socket::SSL : Socket::POLL);
  ASSERT_SOME(create);

  Socket socket = create.get();

  Try<net::IP> ip = net::IP::parse(flags.server, AF_INET);
  EXPECT_SOME(ip);

  // Connect to the server socket located at `ip:port`.
  const Future<Nothing> connect =
    socket.connect(Address(ip.get(), flags.port));

  // Verify that the client views the connection as established.
  AWAIT_EXPECT_READY(connect);

  // Send 'data' from the client to the server.
  AWAIT_EXPECT_READY(socket.send(flags.data));

  // Verify the client received the message back from the server.
  AWAIT_EXPECT_EQ(flags.data, socket.recv());
}
开发者ID:fin09pcap,项目名称:mesos,代码行数:27,代码来源:ssl_client.cpp


示例13: CleanupExit

void CleanupExit()
{
	if (NULL != _sessionManager)
	{
		delete _sessionManager;
		_sessionManager = NULL;
	}
	
	g_AS3Network.closeConnection();
	g_Connected = 0;
	
	removeListeners();
	delete _broadcaster;
	delete _waveDetector;
	delete _pushDetector;
	delete _swipeDetector;
	delete _steadyDetector;
	delete _circleDetector;
	delete _leftRightSlider;
	delete _upDownSlider;
	delete _inOutSlider;
	delete _trackPad;
	
	_context.Shutdown();
	if(_featureSinglePoint) close(POINT_SOCKET);
	if(_featureSlider) close(SLIDER_SOCKET);
	if(_featureUserTracking) close(USER_TRACKING_SOCKET);
	close(SESSION_SOCKET);
	exit(1);
}
开发者ID:alfiandosengkey,项目名称:as3openni,代码行数:30,代码来源:main.cpp


示例14: setupServer

void setupServer() 
{
	g_Connected = 1;
	if (pthread_create(&g_ServerThread, NULL, &serverData, NULL)) 
	{
		fprintf(stderr, "AS3OpenNI :: Error on pthread_create() for the server\n");
	}
	g_AS3Network.sendMessage(0,0,0);
}
开发者ID:alfiandosengkey,项目名称:as3openni,代码行数:9,代码来源:main.cpp


示例15: GetParam

// Test a basic back-and-forth communication within the same OS
// process.
TEST_P(SSLTest, BasicSameProcess)
{
  os::setenv("LIBPROCESS_SSL_ENABLED", "true");
  os::setenv("LIBPROCESS_SSL_KEY_FILE", key_path().string());
  os::setenv("LIBPROCESS_SSL_CERT_FILE", certificate_path().string());
  os::setenv("LIBPROCESS_SSL_REQUIRE_CERT", "true");
  os::setenv("LIBPROCESS_SSL_CA_DIR", os::getcwd());
  os::setenv("LIBPROCESS_SSL_CA_FILE", certificate_path().string());
  os::setenv("LIBPROCESS_SSL_VERIFY_IPADD", GetParam());

  openssl::reinitialize();

  const Try<Socket> server_create = Socket::create(Socket::SSL);
  ASSERT_SOME(server_create);

  const Try<Socket> client_create = Socket::create(Socket::SSL);
  ASSERT_SOME(client_create);

  Socket server = server_create.get();
  Socket client = client_create.get();

  // We need to explicitly bind to INADDR_LOOPBACK so the certificate
  // we create in this test fixture can be verified.
  ASSERT_SOME(server.bind(Address(net::IP(INADDR_LOOPBACK), 0)));

  const Try<Nothing> listen = server.listen(BACKLOG);
  ASSERT_SOME(listen);

  const Try<Address> server_address = server.address();
  ASSERT_SOME(server_address);

  const Future<Socket> _socket = server.accept();

  const Future<Nothing> connect = client.connect(server_address.get());

  // Wait for the server to have accepted the client connection.
  AWAIT_ASSERT_READY(_socket);
  Socket socket = _socket.get(); // TODO(jmlvanre): Remove const copy.

  // Verify that the client also views the connection as established.
  AWAIT_ASSERT_READY(connect);

  // Send a message from the client to the server.
  const string data = "Hello World!";
  AWAIT_ASSERT_READY(client.send(data));

  // Verify the server received the message.
  AWAIT_ASSERT_EQ(data, socket.recv());

  // Send the message back from the server to the client.
  AWAIT_ASSERT_READY(socket.send(data));

  // Verify the client received the message.
  AWAIT_ASSERT_EQ(data, client.recv());
}
开发者ID:SStar1314,项目名称:mesos,代码行数:57,代码来源:ssl_tests.cpp


示例16: UserCalibration_CalibrationEnd

void XN_CALLBACK_TYPE UserCalibration_CalibrationEnd(SkeletonCapability& capability, XnUserID nId, XnBool bSuccess, void* pCookie)
{
	if (bSuccess)
	{
		if(_printUserTracking) printf("AS3OpenNI :: Calibration complete, start tracking user: %d\n", nId);
		_userGenerator.GetSkeletonCap().StartTracking(nId);
		
		char cValue[50];
		sprintf(cValue, "user_tracking_user_calibration_complete:%d", nId);
		if(_useSockets) 
		{
			#if (XN_PLATFORM == XN_PLATFORM_WIN32)
				g_AS3Network.sendMessage(1,8,nId);
			#else
				sendToSocket(USER_TRACKING_SOCKET, cValue);
			#endif
		}
	}
	else
	{
		if(_printUserTracking) printf("AS3OpenNI :: Calibration failed for user: %d\n", nId);
		if (_needPose)
		{
			_userGenerator.GetPoseDetectionCap().StartPoseDetection(_strPose, nId);
		}
		else
		{
			_userGenerator.GetSkeletonCap().RequestCalibration(nId, true);
		}
		
		char cValue[50];
		sprintf(cValue, "user_tracking_user_calibration_failed:%d", nId);
		if(_useSockets) 
		{
			#if (XN_PLATFORM == XN_PLATFORM_WIN32)
				g_AS3Network.sendMessage(1,9,nId);
			#else
				sendToSocket(USER_TRACKING_SOCKET, cValue);
			#endif
		}
	}
}
开发者ID:alfiandosengkey,项目名称:as3openni,代码行数:42,代码来源:main.cpp


示例17: UserCalibration_CalibrationStart

void XN_CALLBACK_TYPE UserCalibration_CalibrationStart(SkeletonCapability& capability, XnUserID nId, void* pCookie)
{
	if(_printUserTracking) printf("AS3OpenNI :: Calibration started for user: %d\n", nId);
	
	char cValue[50];
	sprintf(cValue, "user_tracking_user_calibration_start:%d", nId);
	if(_useSockets) 
	{
		#if (XN_PLATFORM == XN_PLATFORM_WIN32)
			g_AS3Network.sendMessage(1,7,nId);
		#else
			sendToSocket(USER_TRACKING_SOCKET, cValue);
		#endif
	}
}
开发者ID:alfiandosengkey,项目名称:as3openni,代码行数:15,代码来源:main.cpp


示例18: User_LostUser

void XN_CALLBACK_TYPE User_LostUser(UserGenerator& generator, XnUserID nId, void* pCookie)
{
	if(_printUserTracking) printf("AS3OpenNI :: Lost user: %d\n", nId);
	
	char cValue[50];
	sprintf(cValue, "user_tracking_lost_user:%d", nId);
	if(_useSockets) 
	{
		#if (XN_PLATFORM == XN_PLATFORM_WIN32)
			g_AS3Network.sendMessage(1,3,nId);
		#else
			sendToSocket(USER_TRACKING_SOCKET, cValue);
		#endif
	}
}
开发者ID:alfiandosengkey,项目名称:as3openni,代码行数:15,代码来源:main.cpp


示例19: UserPose_PoseDetected

void XN_CALLBACK_TYPE UserPose_PoseDetected(PoseDetectionCapability& capability, const XnChar* strPose, XnUserID nId, void* pCookie)
{
	if(_printUserTracking) printf("AS3OpenNI :: Pose %s detected for user: %d\n", strPose, nId);
	_userGenerator.GetPoseDetectionCap().StopPoseDetection(nId);
	_userGenerator.GetSkeletonCap().RequestCalibration(nId, true);
	
	char cValue[50];
	sprintf(cValue, "user_tracking_pose_detected:%d", nId);
	if(_useSockets) 
	{
		#if (XN_PLATFORM == XN_PLATFORM_WIN32)
			g_AS3Network.sendMessage(1,6,nId);
		#else
			sendToSocket(USER_TRACKING_SOCKET, cValue);
		#endif
	}
}
开发者ID:alfiandosengkey,项目名称:as3openni,代码行数:17,代码来源:main.cpp


示例20: User_NewUser

void XN_CALLBACK_TYPE User_NewUser(UserGenerator& generator, XnUserID nId, void* pCookie)
{
	if(_printUserTracking) printf("AS3OpenNI :: New User: %d\n", nId);
	if(_needPose)
	{
		_userGenerator.GetPoseDetectionCap().StartPoseDetection(_strPose, nId);
	}
	else
	{
		_userGenerator.GetSkeletonCap().RequestCalibration(nId, true);
	}
	
	char cValue[50];
	sprintf(cValue, "user_tracking_new_user:%d", nId);
	if(_useSockets) 
	{
		#if (XN_PLATFORM == XN_PLATFORM_WIN32)
			g_AS3Network.sendMessage(1,2,nId);
		#else
			sendToSocket(USER_TRACKING_SOCKET, cValue);
		#endif
	}
}
开发者ID:alfiandosengkey,项目名称:as3openni,代码行数:23,代码来源:main.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ nglPath类代码示例发布时间:2022-05-31
下一篇:
C++ netnode类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap