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

C++ client函数代码示例

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

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



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

示例1: deref

bool ResourceHandle::onRequestComplete()
{
    if (!d->m_internetHandle) { // 0 if canceled.
        deref(); // balances ref in start
        return false;
    }

    if (d->m_bytesRemainingToWrite) {
        DWORD bytesWritten;
        InternetWriteFile(d->m_requestHandle,
                          d->m_formData.data() + (d->m_formData.size() - d->m_bytesRemainingToWrite),
                          d->m_bytesRemainingToWrite,
                          &bytesWritten);
        d->m_bytesRemainingToWrite -= bytesWritten;
        if (d->m_bytesRemainingToWrite)
            return true;
        d->m_formData.clear();
    }

    if (!d->m_sentEndRequest) {
        HttpEndRequestW(d->m_requestHandle, 0, 0, reinterpret_cast<DWORD_PTR>(this));
        d->m_sentEndRequest = true;
        return true;
    }

    static const int bufferSize = 32768;
    char buffer[bufferSize];
    INTERNET_BUFFERSA buffers;
    buffers.dwStructSize = sizeof(INTERNET_BUFFERSA);
    buffers.lpvBuffer = buffer;
    buffers.dwBufferLength = bufferSize;

    BOOL ok = FALSE;
    while ((ok = InternetReadFileExA(d->m_requestHandle, &buffers, d->m_loadSynchronously ? 0 : IRF_NO_WAIT, reinterpret_cast<DWORD_PTR>(this))) && buffers.dwBufferLength) {
        if (!d->m_hasReceivedResponse) {
            d->m_hasReceivedResponse = true;

            ResourceResponse response;
            response.setURL(firstRequest().url());

            String httpStatusText = queryHTTPHeader(d->m_requestHandle, HTTP_QUERY_STATUS_TEXT);
            if (!httpStatusText.isNull())
                response.setHTTPStatusText(httpStatusText);

            String httpStatusCode = queryHTTPHeader(d->m_requestHandle, HTTP_QUERY_STATUS_CODE);
            if (!httpStatusCode.isNull())
                response.setHTTPStatusCode(httpStatusCode.toInt());

            String httpContentLength = queryHTTPHeader(d->m_requestHandle, HTTP_QUERY_CONTENT_LENGTH);
            if (!httpContentLength.isNull())
                response.setExpectedContentLength(httpContentLength.toInt());

            String httpContentType = queryHTTPHeader(d->m_requestHandle, HTTP_QUERY_CONTENT_TYPE);
            if (!httpContentType.isNull()) {
                response.setMimeType(extractMIMETypeFromMediaType(httpContentType));
                response.setTextEncodingName(extractCharsetFromMediaType(httpContentType));
            }

            if (ResourceHandleClient* resourceHandleClient = client())
                resourceHandleClient->didReceiveResponse(this, response);
        }

        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=19793
        // -1 means we do not provide any data about transfer size to inspector so it would use
        // Content-Length headers or content size to show transfer size.
        if (ResourceHandleClient* resourceHandleClient = client())
            resourceHandleClient->didReceiveData(this, buffer, buffers.dwBufferLength, -1);
        buffers.dwBufferLength = bufferSize;
    }

    if (!ok && GetLastError() == ERROR_IO_PENDING)
        return true;

    if (ResourceHandleClient* resourceHandleClient = client())
        resourceHandleClient->didFinishLoading(this, 0);

    InternetCloseHandle(d->m_requestHandle);
    InternetCloseHandle(d->m_connectHandle);
    deref(); // balances ref in start
    return false;
}
开发者ID:Anthony-Biget,项目名称:openjfx,代码行数:81,代码来源:ResourceHandleWin.cpp


示例2: switch

/// \cond
bool QXmppRosterManager::handleStanza(const QDomElement &element)
{
    if (element.tagName() != "iq" || !QXmppRosterIq::isRosterIq(element))
        return false;

    // Security check: only server should send this iq
    // from() should be either empty or bareJid of the user
    const QString fromJid = element.attribute("from");
    if (!fromJid.isEmpty() && QXmppUtils::jidToBareJid(fromJid) != client()->configuration().jidBare())
        return false;

    QXmppRosterIq rosterIq;
    rosterIq.parse(element);

    bool isInitial = (d->rosterReqId == rosterIq.id());
    switch(rosterIq.type())
    {
    case QXmppIq::Set:
        {
            // send result iq
            QXmppIq returnIq(QXmppIq::Result);
            returnIq.setId(rosterIq.id());
            client()->sendPacket(returnIq);

            // store updated entries and notify changes
            const QList<QXmppRosterIq::Item> items = rosterIq.items();
            foreach (const QXmppRosterIq::Item &item, items) {
                const QString bareJid = item.bareJid();
                if (item.subscriptionType() == QXmppRosterIq::Item::Remove) {
                    if (d->entries.remove(bareJid)) {
                        // notify the user that the item was removed
                        emit itemRemoved(bareJid);
                    }
                } else {
                    const bool added = !d->entries.contains(bareJid);
                    d->entries.insert(bareJid, item);
                    if (added) {
                        // notify the user that the item was added
                        emit itemAdded(bareJid);
                    } else {
                        // notify the user that the item changed
                        emit itemChanged(bareJid);
                    }

                    // FIXME: remove legacy signal
                    emit rosterChanged(bareJid);
                }
            }
        }
        break;
    case QXmppIq::Result:
        {
            const QList<QXmppRosterIq::Item> items = rosterIq.items();
            foreach (const QXmppRosterIq::Item &item, items) {
                const QString bareJid = item.bareJid();
                d->entries.insert(bareJid, item);
                if (!isInitial)
                    emit rosterChanged(bareJid);
            }
            if (isInitial)
            {
                d->isRosterReceived = true;
                emit rosterReceived();
            }
            break;
        }
    default:
        break;
    }

    return true;
}
开发者ID:mik9,项目名称:qt-radio-t-client,代码行数:73,代码来源:QXmppRosterManager.cpp


示例3: main

int main(int argc, char* argv[])
{
    return client();
}
开发者ID:iwallee,项目名称:rdp,代码行数:4,代码来源:client.cpp


示例4: loaderClient

FrameLoaderClient* LocalFrame::loaderClient() const
{
    return static_cast<FrameLoaderClient*>(client());
}
开发者ID:takaaptech,项目名称:sky_engine,代码行数:4,代码来源:LocalFrame.cpp


示例5: throw

Client Client::create(ClientConfig config) throw (voltdb::Exception, voltdb::LibEventException) {
    Client client(new ClientImpl(config));
    return client;
}
开发者ID:debanjan-basu,项目名称:voltdb-client-cpp,代码行数:4,代码来源:Client.cpp


示例6: return

// Alsa handles accessors.
int qjackctlAlsaPort::alsaClient (void) const
{
	return (static_cast<qjackctlAlsaClient *> (client()))->alsaClient();
}
开发者ID:eurogiciel-oss,项目名称:qjackctl,代码行数:5,代码来源:qjackctlAlsaConnect.cpp


示例7: client

 virtual ~CollectionBase() {
     client().dropCollection( ns() );
 }
开发者ID:Desartstudio,项目名称:mongo-nonx86,代码行数:3,代码来源:matchertests.cpp


示例8: client

void PopupMenuHaiku::updateFromElement()
{
    client()->setTextFromItem(m_popupClient->selectedIndex());
}
开发者ID:achellies,项目名称:WinCEWebKit,代码行数:4,代码来源:PopupMenuHaiku.cpp


示例9: main

int main(int argc, char *argv[])
{
    char command[2];
    memset(command, 0, 2);
    rtspClient client(streamUri, servIP, port);
    while(1){
        
	fprintf(stdout, "please input the command:\n"
		"-[method option]:\n"
		"-b setup         \n"
		"-p play          \n"
		"-t teardown      \n"
		"-w move up       \n"
		"-s move down     \n"
		"-a move left     \n"
		"-d move right    \n"
		"-c click         \n"
                "-0~9 input number\n"
                "-e backspace     \n"
                "-n enter         \n"
		"-q quit          \n");
	fprintf(stdout, ">");
	fscanf(stdin, "%s", command);
        switch(command[0]){
		case 'b':
			client.Setup();
			break;
		case 'p':
			client.Play();
			break;
		case 't':
			client.Teardown();
			break;
		case 'w':
			client.Play('w');
			break;
		case 's':
			client.Play('s');
			break;
		case 'a':
			client.Play('a');
			break;
		case 'd':
			client.Play('d');
			break;
		case 'c':
			client.Play('c');
			break;
		case '0':
			client.Play('0');
			break;
		case '1':
			client.Play('1');
			break;
		case '2':
			client.Play('2');
			break;
		case '3':
			client.Play('3');
			break;
		case '4':
			client.Play('4');
			break;
		case '5':
			client.Play('5');
			break;
		case '6':
			client.Play('6');
			break;
		case '7':
			client.Play('7');
			break;
		case '8':
			client.Play('8');
			break;
		case '9':
			client.Play('9');
			break;
		case 'e':
			client.Play('e');
			break;
		case 'n':
			client.Play('n');
			break;
		case 'q':
			return 0;
			break;
		default:
			fprintf(stdout, "Illegal Input!\n");
			break;
	}
    }
    return 0;
  
}
开发者ID:arccosxy,项目名称:alexis,代码行数:95,代码来源:main.cpp


示例10: DSTACK

void TestConnection::testConnectSendReceive()
{
	DSTACK("TestConnection::Run");

	/*
		Test some real connections

		NOTE: This mostly tests the legacy interface.
	*/

	u32 proto_id = 0xad26846a;

	Handler hand_server("server");
	Handler hand_client("client");

	Address address(0, 0, 0, 0, 30001);
	Address bind_addr(0, 0, 0, 0, 30001);
	/*
	 * Try to use the bind_address for servers with no localhost address
	 * For example: FreeBSD jails
	 */
	std::string bind_str = g_settings->get("bind_address");
	try {
		bind_addr.Resolve(bind_str.c_str());

		if (!bind_addr.isIPv6()) {
			address = bind_addr;
		}
	} catch (ResolveError &e) {
	}

	infostream << "** Creating server Connection" << std::endl;
	con::Connection server(proto_id, 512, 5.0, false, &hand_server);
	server.Serve(address);

	infostream << "** Creating client Connection" << std::endl;
	con::Connection client(proto_id, 512, 5.0, false, &hand_client);

	UASSERT(hand_server.count == 0);
	UASSERT(hand_client.count == 0);

	sleep_ms(50);

	Address server_address(127, 0, 0, 1, 30001);
	if (address != Address(0, 0, 0, 0, 30001)) {
		server_address = bind_addr;
	}

	infostream << "** running client.Connect()" << std::endl;
	client.Connect(server_address);

	sleep_ms(50);

	// Client should not have added client yet
	UASSERT(hand_client.count == 0);

	try {
		NetworkPacket pkt;
		infostream << "** running client.Receive()" << std::endl;
		client.Receive(&pkt);
		infostream << "** Client received: peer_id=" << pkt.getPeerId()
			<< ", size=" << pkt.getSize() << std::endl;
	} catch (con::NoIncomingDataException &e) {
	}

	// Client should have added server now
	UASSERT(hand_client.count == 1);
	UASSERT(hand_client.last_id == 1);
	// Server should not have added client yet
	UASSERT(hand_server.count == 0);

	sleep_ms(100);

	try {
		NetworkPacket pkt;
		infostream << "** running server.Receive()" << std::endl;
		server.Receive(&pkt);
		infostream << "** Server received: peer_id=" << pkt.getPeerId()
				<< ", size=" << pkt.getSize()
				<< std::endl;
	} catch (con::NoIncomingDataException &e) {
		// No actual data received, but the client has
		// probably been connected
	}

	// Client should be the same
	UASSERT(hand_client.count == 1);
	UASSERT(hand_client.last_id == 1);
	// Server should have the client
	UASSERT(hand_server.count == 1);
	UASSERT(hand_server.last_id == 2);

	//sleep_ms(50);

	while (client.Connected() == false) {
		try {
			NetworkPacket pkt;
			infostream << "** running client.Receive()" << std::endl;
			client.Receive(&pkt);
			infostream << "** Client received: peer_id=" << pkt.getPeerId()
//.........这里部分代码省略.........
开发者ID:ChunHungLiu,项目名称:freeminer,代码行数:101,代码来源:test_connection.cpp


示例11: client

void WebLocalFrameImpl::didFail(const ResourceError& error)
{
    if (!client())
        return;
    client()->didFailLoad(this, error);
}
开发者ID:Jamesducque,项目名称:mojo,代码行数:6,代码来源:WebLocalFrameImpl.cpp


示例12: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
    std::array<std::string, 4> ar{ { "The boost::asio::buffer() function provides a convenient way "
        "to create the buffer classes, where the size of the buffer is "
        "deduced from the type possible.",
        "When Boost.Asio is able to deduce the buffer length, then Boost.",
        "The compiler expects to get an int and not an initializer-list, "
        "that's the reason for the error.",
        "The fundamental question becomes how does one know how much memory "
        "to allocate, if Boost.Asio does not transmit the size." } };
    std::string str = "The compiler expects to get an int and not an initializer-list, that's the reason for the error.";
    /*
    std::array<int, 10> ar1{ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 } };
    std::vector<std::thread> threads;
    printer pr;
    for (int i = 0; i < 4; i++)
    {
        threads.push_back(std::thread([&pr, i, &ar]()
        {
            pr.print_msg(ar[i]);
            std::chrono::milliseconds duration(500);
            std::this_thread::sleep_for(duration);
            pr.print_msg(ar[i]);
        }));
    }
    for (std::thread &t : threads)
        t.join();
    */
    try
    {
        io_service service_server;
        echo_server server(service_server);
        getline(std::cin, str);
        if (str == "1")
        {
            std::thread t1([&service_server]() { service_server.run(); });
            while (true)
            {
                getline(std::cin, str);
                if (str == "exit")
                {
                    server.stop_accept();
                    break;
                }
                io_service service_client;
                echo_client client(service_client, str);
                std::thread t2([&service_client]() { service_client.run(); });
                t2.join();
            }
            t1.join();
        }
        else
        {
            ///*
            std::thread main_thread([&service_server]() { service_server.run(); });
            while (true)
            {
                getline(std::cin, str);
                if (str == "exit")
                {
                    server.stop_accept();
                    break;
                }
                std::vector<std::unique_ptr<io_service>> clients_services;
                std::vector<std::unique_ptr<echo_client>> clients;
                std::vector<std::thread> threads;
                for (int i = 0; i < 4; i++)
                {
                    clients_services.emplace_back(new io_service());
                    //echo_client client(*clients_services[i], ar[i]);
                    clients.emplace_back(new echo_client(*clients_services[i], ar[i]));
                    threads.push_back(std::thread([i, &clients_services]() { clients_services[i]->run(); }));
                }
                for (auto & t : threads)
                    t.join();
            }
            main_thread.join();
            std::cout << "Main thread exit" << std::endl;
            //*/
        }
    }
    catch (std::exception &e)
    {
        std::cout << e.what() << std::endl;
    }

    system("pause");
    return 0;
}
开发者ID:koshinus,项目名称:CPP_programs,代码行数:89,代码来源:test.cpp


示例13: main

int main( int argc, char *argv[] )
{
	// catch process signals
	signal( SIGINT, term );
	signal( SIGTERM, term );

	int ret = EXIT_SUCCESS;
	string filename = "";
	string name = "fogboxrecv";
	int timeout = 1;
	int count   = 1;


	system( "mkdir -p /root/rsync/media/USER1/" );
	system( "mkdir -p /root/rsync/media/USER2/" );
	system( "mkdir -p /root/rsync/media/USER3/" );
	system( "mkdir -p /root/rsync/media/USER4/" );





	try {
		// Create a stream to the server using TCP.
		ibrcommon::tcpclient conn;

		// connect to the standard local api port
		conn.open( "127.0.0.1", 4550 );

		// enable nodelay option
		conn.enableNoDelay();

		// Initiate a client for synchronous receiving
		dtn::api::Client client( name, conn );

		// export objects for the signal handler
		_conn = &conn;
		_client = &client;

		// Connect to the server. Actually, this function initiate the
		// stream protocol by starting the thread and sending the contact header.
		client.connect();

// 		std::fstream file;

// 		if (!_stdout)
// 		{
// 			std::cout << "Wait for incoming bundle... " << std::endl;
// 			file.open(filename.c_str(), ios::in|ios::out|ios::binary|ios::trunc);
// 			file.exceptions(std::ios::badbit | std::ios::eofbit);
// 		}

		while( run == true )
		{
			// receive the bundle
			dtn::api::Bundle b = client.getBundle( timeout );

			cout << "recvd a bundle" << endl;

			// get the reference to the blob
			ibrcommon::BLOB::Reference ref = b.getData();
			struct timeval now;
			::gettimeofday( &now, 0 );

			fstream tmpfile;
			tmpfile.open( "/root/rsync/media/tmpfile", ios::in|ios::out|ios::binary|ios::trunc );
			tmpfile.exceptions( std::ios::badbit | std::ios::eofbit );

			tmpfile << ref.iostream()->rdbuf();
// 			tmpfile.close();

			cout << "wrote to temp file" << endl;

			tmpfile.seekg ( 0, ios::beg );
			cout << "seek to beg" << endl;

			char c[256];
			tmpfile.get( c,256 );

			stringstream filename;

			int counter = 0;
			while ( c[counter] != '|' )
				filename << c[counter++];

			cout << "filename is " << filename.str() << endl;

			fstream actualfile;
			actualfile.open( filename.str().c_str(), ios::in|ios::out|ios::binary|ios::trunc );
			actualfile.exceptions( std::ios::badbit | std::ios::eofbit );

			tmpfile.seekg ( 0, ios::beg );
			tmpfile.seekg ( counter+3 );
			actualfile << tmpfile.rdbuf();

			cout << "wrote to real file " << endl;

			tmpfile.close();
			actualfile.close();

//.........这里部分代码省略.........
开发者ID:ZareenaSameer,项目名称:distressnet,代码行数:101,代码来源:fogboxrecv.cpp


示例14: main

int main()
{
  protolayer::server::Client client(80000);
  client.shutdown();
  return 0;
}
开发者ID:williamwaterson,项目名称:protolayer,代码行数:6,代码来源:shutdown.cpp


示例15: EXEC_JUBATUS_COMMAND

bool QJubatusClustering::push(const QList<IndexedPoint> &data)
{
    bool ret = false;
    EXEC_JUBATUS_COMMAND( ret = client()->push(convert(data)); )
    return ret;
开发者ID:qt-users-jp,项目名称:qmlplugins-jubatus,代码行数:5,代码来源:qjubatusclustering.cpp


示例16: main


//.........这里部分代码省略.........
    if (strcmp("-src", argv[2]) != 0) {
        print_usage();
        exit(1);
    }
    
    if (strcmp("-d", argv[4]) != 0) {
        print_usage();
        exit(1);
    }
    
    if (strcmp("-i", argv[6]) != 0) {
        print_usage();
        exit(1);
    }
    
    src = (uint16_t) atoi(argv[3]);
    keystoredir = strdup(argv[5]);
    
    
    // Remove / if the dirname ends with a slash
    if (keystoredir[strlen(keystoredir)-1] == '/') {
        keystoredir[strlen(keystoredir)-1] = '\0';
    }
    
    // Check if the keystore directory exists
    if (stat(keystoredir, &s) == -1) {
        fprintf(stderr, "Error: keystore %s does not exist\n", keystoredir);
        exit(1);
    }
    else {
        if(!S_ISDIR(s.st_mode)) {
            fprintf(stderr, "Error: keystore %s is not a directory\n", keystoredir);
            exit(1);
        }
    }
    
    arg_interface = strdup(argv[7]);
    
    /*
     * Network Interfaces
     *
     */
    // Count commas to get the upper bound of the number of interfaces
    for (i=0; i<strlen(arg_interface); i++) {
        if (arg_interface[i] == ',') num_input_interfaces++;
    }
    num_input_interfaces++;
    
    // Allocate input interface array
    input_interface = (struct interface *) malloc(num_input_interfaces * sizeof(struct interface));
    
    // Parse input interfaces
    num_input_interfaces = 0;
    dup = strdup(arg_interface);
    while ((token = strtok(dup, ",")) != NULL) {
        
        strcpy(input_interface[num_input_interfaces].interface_name, token);
        fill_interface_info(&input_interface[num_input_interfaces]);
        
        // Interface name is valid
        if (input_interface[num_input_interfaces].interface_index != -1) {
            num_input_interfaces++;
        }
        
        dup = NULL;
        
    }
    free(arg_interface);
    free(token);
    
    // Check if the number of interfaces is at least 1
    if (num_input_interfaces <= 0) {
        fprintf(stderr, "Error: no valid network interfaces\n");
        exit(1);
    }
    
    // Print listening interfaces information
    #ifdef _VERBOSE
    fprintf(stderr, "[NETWORK INTERFACES]\n");
    fprintf(stderr, "   Number of network interfaces: %d\n", num_input_interfaces);
    fprintf(stderr, "   %-5s %-6s %-19s %-15s\n", "Dev", "DevId", "Interface MAC addr", "Inf IP addr");
    for(i=0; i<num_input_interfaces; i++) {
        fprintf(stderr, "%2d ", i+1);
        fprintf_interface(stderr, &input_interface[i]);
    }
    fprintf(stderr, "\n");
    #endif
    
    
    
    if (strcmp("-s", argv[1]) == 0) {
        server(src, keystoredir, num_input_interfaces, &input_interface);
    }
    else if (strcmp("-c", argv[1]) == 0) {
        client(src, keystoredir, num_input_interfaces, &input_interface);
    }
    
    return 0;
    
}
开发者ID:SanthoshGunturu,项目名称:finalproject,代码行数:101,代码来源:main.c


示例17: main

int main(int argc, char **argv) {

	//First we read our arguments from the command line
	while ((c = getopt (argc, argv, "kl:vrw:p:")) != -1)
		switch(c)
		{
			case 'l':
				listenPort = optarg;
				lflag = 1;
				break;
			case 'k':
				kflag = 1;
				break;
			case 'v':
				vflag = 1;
				break;
			case 'w':
				wflag = 1;
				timeOut = atoi(optarg);
				break;
			case 'r':
				rflag = 1;
				break;
			case 'p':
				pflag = 1;
				sourcePort = atoi(optarg);
				break;
			default:
				usage(argv[0]);
				exit(1);
		}

	  //Get hostname and destination port only if -l is not on
	  if (lflag != 1){
		  argn = optind;
		  hostName = argv[argn];
		  //Make sure a port was provided in argv, or we will get a seg fault
		  if(argn+1 >= argc){
		  	usage(argv[0]);
		  	exit(1);
		  } else {
		  	destPort = argv[argn+1];
		  }
		}

	//It is an error to use the -k option without the -l option.
	if(kflag == 1 && lflag == 0){
		usage(argv[0]);
		exit(1);
	}
	
	//It is an error to use the -p option in conjunction with the -l option.
	if (lflag == 1 && pflag ==1){
		usage(argv[0]);
		exit(1);
	}

	//The r option can only be used with the -l option
	if (rflag == 1 && lflag == 0){
		usage(argv[0]);
		exit(1);
	}

	//The w cannot be used with the l option
	if (wflag == 1 && lflag == 1){
		usage(argv[0]);
		exit(1);
	}

    //For debugging
    if(vflag){
	    printf ("kflag = %d, lflag = %d, vflag = %d, wflag= %d, rflag= %d, pflag =%d\n",
		kflag, lflag, vflag, wflag, rflag, pflag);
		printf("The time out is : %d\n", timeOut);
		printf("The sourcePort num is : %d\n", sourcePort);
		printf("The listenPort num is : %s\n", listenPort);
		printf("The hostName num is : %s\n", hostName);
		printf("The destPort num is : %s\n", destPort);
	}

	//Call server() function for -l flag
	if(lflag){
		server(listenPort, kflag);
	}

	//For client
	if(lflag == 0){
		client(hostName, destPort);
	}

    return 0;

}
开发者ID:bollain,项目名称:netClone,代码行数:93,代码来源:ncTh.c


示例18: client

bool SpellChecker::canCheckAsynchronously(Node* node) const
{
    return client() && isCheckable(node) && isAsynchronousEnabled() && !isBusy();
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:4,代码来源:SpellChecker.cpp


示例19: main

int main(int argc, char *argv[])
{
    if (argc < 3) {
        printf( "Usage:   %s <statsd_host> <statsd_port> [<eth_interface>] [<refresh_rate_seconds>]\n"
                "  where: eth_interface        - default: eth0\n"
                "         refresh_rate_seconds - default: 1\n\n"
                "Example: %s 127.0.0.1 8125\n",
                argv[0], argv[0]);
        exit(1);
    }

    string statsdHost = argv[1];
    int statsdPort = atoi(argv[2]);
    string ethInterface = "eth0";
    int refreshSeconds = 1;
    if (argc > 3) {
        ethInterface = argv[3];
        if (argc == 5) {
            refreshSeconds = atoi(argv[4]);
        }
    }

    signal(SIGHUP, SIG_IGN);
    signal(SIGPIPE, SIG_IGN);
    signal(SIGCHLD, SIG_IGN); /* will save one syscall per sleep */
    signal(SIGTERM, sigterm);

    string ns = string("himond.") + getHostname().c_str() + ".";
    statsd::StatsdClient client(statsdHost, statsdPort, ns);
    SystemMonitor *sysmon = new SystemMonitor(true, true, true, ethInterface, refreshSeconds);

    printf("himond - running in background...\n");
    daemon(0,0);

    int secondsPassed = 0;
    unsigned long
        uptime,
        memTotal, memUsed, memFree,
        virtMemTotal, virtMemUsed, virtMemFree,
        diskTotal, diskUsed, diskFree;
    unsigned long long
        diskReadRate, diskWriteRate,
        netRecvRate, netSendRate;
    int cpuCount;
    float cpuUsage;

    while (running) {
        sleep(1);
        secondsPassed++;

        // gathering stats
        uptime   = sysmon->getSystemUptime(); // secs
        // MB
        memTotal = sysmon->getMemoryTotal();
        memUsed  = sysmon->getMemoryUsed();
        memFree  = sysmon->getMemoryFree();
        // MB
        virtMemTotal = sysmon->getVirtualMemoryTotal();
        virtMemUsed  = sysmon->getVirtualMemoryUsed();
        virtMemFree  = sysmon->getVirtualMemoryFree();
        // MB
        diskTotal = sysmon->getDiskTotal();
        diskUsed  = sysmon->getDiskUsed();
        diskFree  = sysmon->getDiskFree();
        // kbps
        diskReadRate  = sysmon->getDiskReadRate();
        diskWriteRate = sysmon->getDiskWriteRate();
        // kbps
        netRecvRate = sysmon->getRxRate();
        netSendRate = sysmon->getTxRate();

        cpuCount = sysmon->getProcessorCount();
        cpuUsage = sysmon->getProcessorUsage();

        if (refreshSeconds >= secondsPassed) {
            // send the stats
            client.count("system.uptime", uptime);

            client.gauge("memory.total", memTotal);
            client.gauge("memory.used", memUsed);
            client.gauge("memory.free", memFree);

            client.gauge("memory.virtual.total", virtMemTotal);
            client.gauge("memory.virtual.used", virtMemUsed);
            client.gauge("memory.virtual.free", virtMemFree);

            client.gauge("disk.total", diskTotal);
            client.gauge("disk.used", diskUsed);
            client.gauge("disk.free", diskFree);

            client.count("disk.rate.read", diskReadRate);
            client.count("disk.rate.write", diskWriteRate);

            client.count("net.rate.recv", netRecvRate);
            client.count("net.rate.send", netSendRate);

            client.gauge("cpu.count", cpuCount);
            client.gauge("cpu.usage", cpuUsage);

            secondsPassed = 0;
//.........这里部分代码省略.........
开发者ID:bartoffw,项目名称:himond,代码行数:101,代码来源:himond.cpp


示例20: main

int main(int argc, char **argv)
{

	int uvmem_fd = open(DEV_UVMEM, O_RDWR);
	if (uvmem_fd < 0) {
		perror("can't open "DEV_UVMEM);
		exit(EXIT_FAILURE);
	}
	printf("uvmem_fd %d\n", uvmem_fd);
	long page_size = sysconf(_SC_PAGESIZE);
	printf("_SC_PAGESIZE = %ld\n", page_size);
	struct uvmem_init uinit = {
		.size = UVMEM_NR_PAGES * page_size,
	};
	printf("UVMEM_INIT = %lu\n", UVMEM_INIT);
	if (ioctl(uvmem_fd, UVMEM_INIT, &uinit) < 0) {
		err(EXIT_FAILURE, "UVMEM_INIT");
	}

	int shmem_fd = uinit.shmem_fd;
	size_t size = uinit.size;

	if (ftruncate(shmem_fd, size) < 0) {
		err(EXIT_FAILURE, "truncate(\"shmem_fd\")");
	}

	printf("uvmem_fd %d shmem_fd %d\n", uvmem_fd, shmem_fd);
	fflush(stdout);

#if 0
	// fork based
	pid_t child = fork();
	if (child < 0) {
		err(EXIT_FAILURE, "fork");
	}
	if (child == 0) {
		// sleep(1);
		printf("server pid: %d\n", getpid());
		server(uvmem_fd, shmem_fd, size, page_size);
		return 0;
	}
#else

	DPRINTF("mmap\n");
	void *ram = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE,
			 uvmem_fd, 0);
	if (ram == MAP_FAILED) {
		err(EXIT_FAILURE, "client: mmap");
	}
	shared_mem = ram;


	pthread_t server_thread;
	pthread_attr_t attr; int rc;
	struct server_arg sarg = {
		.uvmem_fd = uvmem_fd,
		.shmem_fd = shmem_fd,
		.size = size,
		.page_size = page_size,
	};

	rc = pthread_attr_init(&attr);
	if (rc) 
		err(EXIT_FAILURE, "pthread_attr_init");
	rc = pthread_create(&server_thread, &attr, thread_server, &sarg);
	printf("Thread id %u\n", (unsigned int)server_thread);
	if (rc)
		err(EXIT_FAILURE, "pthread_create");
#endif


	// printf("qemu pid: %d server pid: %d\n", getpid(), child);
	// close(shmem_fd);
	// sleep(1);	
	/* wait the daemon is ready
			 * To make it sure, communication with the server
			 * is needed. sleep() is used here for simplicity.
			 */
	client(uvmem_fd, size, page_size);
	return 0;
}
开发者ID:LeoLiangZhang,项目名称:Picocenter-embassies,代码行数:81,代码来源:uvmem_test.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ client_connect函数代码示例发布时间:2022-05-30
下一篇:
C++ clicked函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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