コード例 #1
0
int main()
{
	CClient* myClient = new CClient();
	myClient->Init();
	myClient->Connect("127.0.0.1",60000);

	while(1)
	{
		//.. do stuff
		myClient->Update();
	}

	myClient->Destroy();
	delete myClient;
	
	return 0;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: wolves3d/RoomControl
int main()
{
	CServer server(SERVER_PORT);

	// -------------------------------------------------------------------------

	printf("--- Client ---\n");
	CClient client;
	client.Init("127.0.0.1", SERVER_PORT);

	// -------------------------------------------------------------------------

	//	uint logDelay = 1000 * 60 * 30;
	uint logDelay = 5;
	time_t deadline = 0;
	bool readFlag = false;

	/*
	byte args[] = { 0, 8, 0, 1, 2, 3, 4, 5, 6, 7 };
	g_commMgr->PushCommand(CMD_WRITE_EEPROM, &args, sizeof(args));
	*/

//	arduinoCmdManager.SendCommand(&arduinoPort, CMD_REQUEST_ONE_WIRE_ENUM, NULL, 0);
	
	while (true)
	{
		server.OnUpdate();
		client.OnUpdate();
		
		System::SleepMS(0);
		/*
		if (false == readFlag)
		{
			if (true == device->IsOneWireEnumerated())
			{
				//OnEnumerationDone();
				readFlag = true;

				// test "turn on relay"
				//byte data[] = { 4, 0 };
				//arduinoCmdManager.SendCommand(&arduinoPort, CMD_PIN_WRITE, &data, sizeof(data));
			}
		}

		if (true == readFlag)
		{
			const time_t currentTime = time(NULL);
			if (currentTime >= deadline)
			{
				deadline = (currentTime + logDelay);
				OneWireAddr addr = device->GetOneWireDevice(0);

				arduinoCmdManager.SendCommand(
					&arduinoPort,
					CMD_OW_READ_TEMP_SENSOR_DATA,
					addr.Address(),
					OneWireAddr::ADDR_LEN);
			}
		}
		*/
	}

//	comPort.Close();
	return 0;
}
コード例 #3
0
ファイル: tcpechoclient.cpp プロジェクト: cacls/serverlib
int main(int argc, char **argv)
{
	if (argc < 2)
	{
		printf("usage: -n requests -c concurrency ip:port\n");
		return 0;
	}

	for (int i = 1; i < argc; i++)
	{
		if (argv[i][0] == '-')
		{
			switch(argv[i][1])
			{
			case 'n':
				requests = atoi(argv[i+1]);
				break;
			case 'c':
				concurrency = atoi(argv[i+1]);
				break;
			default:
				break;
			}
			i++;
		}
		else
		{
			std::string url = argv[i];
			int pos = url.find(':');
			ip = url.substr(0, pos);
			port = atoi(url.c_str()+pos+1);
		}
	}


	repeats = requests/concurrency;

	memset((struct sockaddr*)&sock_addr, 0, sizeof(sock_addr));
	sock_addr.sin_family = AF_INET;
	sock_addr.sin_port = htons(port);
	sock_addr.sin_addr.s_addr = inet_addr(ip.c_str());

	struct timeval tv_start, tv_end;
	gettimeofday(&tv_start, NULL);

	for (int i = 0; i < concurrency; ++i)
	{
		CClient * pClient = new CClient();
		pClient->Init();
	}

	ev::sig sig;
	sig.set<&__SigCallback>();
	sig.start(SIGPIPE);
	
	loop.loop();

	gettimeofday(&tv_end, NULL);

	int nUsec = (tv_end.tv_sec-tv_start.tv_sec) * 1000000 + tv_end.tv_usec-tv_start.tv_usec;
	printf("success: \033[1;33m%d\033[0m, fail: \033[1;31m%d\033[0m, time: %d.%06d s\nread: %lld bytes, write: %lld bytes, readrate: %lld KB/s, writerate: %lld KB/s\n", 
		success, requests-success, nUsec/1000000, nUsec%1000000, readbytes, writebytes, readbytes*1000000/nUsec/1024, writebytes*1000000/nUsec/1024);

	return 0;
}