コード例 #1
0
ファイル: tcEthernet.cpp プロジェクト: hanxin1987216/DTL
/**
 *      test case for ping() functions 
 */
void 
TestEthernet::tcPing(void)
{
	cout << "ping 测试 :" << endl;

	char *strIP = NULL;       
	if (Ping(strIP))
	{
		cout << "Ping NULL  成功!" << endl;       
	}
	else
	{
		cout << "Ping NULL 失败!!" << endl;       
	}

	char strIP1[] = "www.datatom.com";       
	if (Ping(strIP1))
	{
		cout << "Ping www.datatom.com 成功!" << endl;       
	}
	else
	{
		cout << "Ping www.datatom.com 失败!!" << endl;       
	}
}
コード例 #2
0
void CRemoteConnection::Update(const bool inInitialConnect)
{
	if (!active)
		return;

	const float curTime = static_cast<float>(SDL_GetTicks())/1000.0f;

	if(inInitialConnect && lastSendTime<curTime-1){		//server hasnt responded so try to send the connection attempt again
		SendRawPacket(unackedPackets[0]->data,unackedPackets[0]->length,0);
		lastSendTime=curTime;
	}
	if(lastSendTime<curTime-5 && !inInitialConnect){		//we havent sent anything for a while so send something to prevent timeout
		Ping();
	}
	if(lastSendTime<curTime-0.2f && !waitingPackets.empty()){	//we have at least one missing incomming packet lying around so send a packet to ensure the other side get a nak
		Ping();
	}

	if(lastReceiveTime < curTime-(inInitialConnect ? 40 : 30))
	{
		active=false;
	}

	if(outgoingLength>0 && (lastSendTime < (curTime-0.2f+outgoingLength*0.01f) || lastSendFrame < gs->frameNum-1)){
		Flush();
	}
}
コード例 #3
0
bool NetworkManager::InitialiseNetworking()
{
	WSADATA wsaData;
	if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) 
	{
		std::cout << "WSAStartup failed." << std::endl;
		return false;
	}
	m_IOSocket = socket(AF_INET, SOCK_DGRAM, 0);
	if(m_IOSocket == SOCKET_ERROR)
	{
	   std::cout << "Error Opening socket: Error " << WSAGetLastError() << std::cout;
	   return false;
	}

	//setup the local (server) address the socket will listen on
	m_LocalAddress.sin_family = AF_INET;
	m_LocalAddress.sin_addr.s_addr = INADDR_ANY;//inet_addr("10.40.61.9")
	m_LocalAddress.sin_port = htons(1328);
	
	//setup the broadcast address
	m_BroadcastAddress.sin_family = AF_INET;
	m_BroadcastAddress.sin_port = htons(1328);
	m_BroadcastAddress.sin_addr.S_un.S_addr = inet_addr("255.255.255.255");

	//bind the socket (so that it listens)
	if(bind(m_IOSocket, (SOCKADDR*) &m_LocalAddress, sizeof(m_LocalAddress)) == SOCKET_ERROR) 
	{
		std::cout << "bind() failed: Error " << WSAGetLastError() << std::cout;
	}
	//automatically reset the socket connection if it exits prematurely
	DWORD dwBytesReturned = 0;
	BOOL bNewBehavior = FALSE;
	WSAIoctl(m_IOSocket,SIO_UDP_CONNRESET,&bNewBehavior,sizeof(bNewBehavior),NULL,0,&dwBytesReturned,NULL,NULL);
	
	//enable broadcasting on this socket
	BOOL bOptVal = TRUE;
	setsockopt(m_IOSocket,SOL_SOCKET,SO_BROADCAST,(const char *)&bOptVal,sizeof(BOOL));
	
	//join multicast group
	/*
	ip_mreq mreq;
	mreq.imr_multiaddr.S_un.S_addr = inet_addr("224.3.2.1");
	mreq.imr_interface.S_un.S_addr = INADDR_ANY;
	setsockopt(m_IOSocket,IPPROTO_IP,IP_ADD_MEMBERSHIP,(const char *)&mreq,sizeof(ip_mreq));
	*/

	//ping the local net a few times
	Ping();
	Ping();
	Ping();
	return true;
}
コード例 #4
0
int CDevWatchdog::Open( const void* devName )
{
	if ( ! devName )
		devName=DEV_WATCHDOG ;

	m_nDevFd = open((const char*)devName, O_RDWR ) ;
	if ( -1 == m_nDevFd )
	{
		PERR( "Unable to open device file[%s]", (const char*)devName ) ;
		return false ;
	}
	struct watchdog_info ident ;
	ioctl(m_nDevFd, WDIOC_GETSUPPORT, &ident);

	if ( ! (ident.options & (WDIOF_KEEPALIVEPING|WDIOF_SETTIMEOUT) )
	   )
	{
		ERR( "features missing: KEEPALIVEPING and SETTIMEOUT");
		systemf_to( 20, "log2flash 'WTD: ERR: features missing: KEEPALIVEPING and SETTIMEOUT'&");
		close(m_nDevFd);
		m_nDevFd = -1 ;
		return false ;
	}
	ioctl(m_nDevFd, WDIOC_GETTIMEOUT, &m_lPingInterval);

	LOG("Found [%s] with %lu seconds timeout", ident.identity, m_lPingInterval);
	systemf_to( 20,"log2flash 'WTD: Found [%s] with %lu seconds timeout'&", ident.identity, m_lPingInterval);
	Ping() ;
	return true ;
}
コード例 #5
0
ファイル: Detection.cpp プロジェクト: huangyt/MyProjects
void Detection::WorkFunc()
{
    CheckIP138();
    CheckIP();
    TestTinydrag();
    Ping();
    GetLocalIP();
    Test9KAPPPAC();
    Test9K();
    Test8888();
    boost::thread work_thread(boost::bind(&Detection::TestTracker, this));
    for (int i = 0; i < 5 * 60; ++i)
    {
        if (i % 3 == 0)
        {
            ++m_progress_pos_;
            if (i % 60 == 0)
            {
                Test9K();
            }
        }
        Sleep(1000);
    }
    Analyze();
    TestBs();
    Test9K();
    WriteTrackerResult();
    Sleep(1000);
    MessageBox("测试完毕!");
}
コード例 #6
0
ファイル: DP_RepMain.cpp プロジェクト: P3tr0viCh/DP_Rep
int TMain::CheckPing() {
	int Result = ID_NO;
	String Host, Phone, S = "";

	ShowWaitCursor();

	TFileIni* FileIni = CreateINIFile();

	for (int i = 1; i <= FileIni->ReadInteger("DB", "Count", 0); i++) {
		ProcMess();

		Host = FileIni->ReadString("DB", "Ping" + IntToStr(i), "");

		if (Host != "")
			if (!Ping(Host))
				S = ConcatStrings(S, Format(IDS_PING_ERROR,
				ARRAYOFCONST((FileIni->ReadString("DB", "Name" + IntToStr(i),
				""), FileIni->ReadString("DB", "Phone" + IntToStr(i), "")))),
				(String) sLineBreak + (String) sLineBreak);
	}

	FileIni->Free();

	RestoreCursor();

	if (S != "")
		Result = MsgBox(S + sLineBreak + sLineBreak + LoadStr(IDS_PING_RESULT),
		MB_YESNOCANCEL | MB_ICONQUESTION);

	return Result;
}
コード例 #7
0
ファイル: C4Network2IO.cpp プロジェクト: 772/openclonk
bool C4Network2IO::Execute(int iTimeout, pollfd *)
{
    tLastExecute = C4TimeMilliseconds::Now();

    // check for timeout
    CheckTimeout();

    // ping all open connections
    if (!Inside(tLastPing, tLastExecute - C4NetPingFreq, tLastExecute))
    {
        Ping();
        tLastPing = tLastExecute;
    }

    // do statistics
    if (!Inside(tLastStatistic, tLastExecute - C4NetStatisticsFreq, tLastExecute))
    {
        GenerateStatistics(tLastExecute - tLastStatistic);
        tLastStatistic = tLastExecute;
    }

    // resources
    ::Network.ResList.OnTimer();

    // ok
    return true;
}
コード例 #8
0
//-----------------------------------------------------------------------------
// Purpose: Target doesn't exist or has eluded us, so search for one
//-----------------------------------------------------------------------------
void CNPC_CombineCamera::SearchThink()
{
	// Allow descended classes a chance to do something before the think function
	if (PreThink(CAMERA_SEARCHING))
		return;

	SetNextThink( gpGlobals->curtime + 0.05f );

	SetIdealActivity((Activity) ACT_COMBINE_CAMERA_OPEN_IDLE);

	if ( !GetTarget() )
	{
		// Try to acquire a new target
		if (MaintainEnemy())
		{
			SetThink( &CNPC_CombineCamera::ActiveThink );
			return;
		}
	}

	// Display that we're scanning
	m_vecGoalAngles.x = 15.0f;
	m_vecGoalAngles.y = GetAbsAngles().y + (sin(gpGlobals->curtime * 2.0f) * 45.0f);

	// Turn and ping
	UpdateFacing();
	Ping();

	SetEyeState(CAMERA_EYE_IDLE);
}
コード例 #9
0
ファイル: ultrasonic.c プロジェクト: rubiktubik/Asuro32
/**
  * @brief  Funktion Ausweichen
  *
  *         Der Asuro benutzt den Ultraschall um die Umgebung zu scannen und weicht
  *         jedem Hinderniss mit einer Rechtsdrehung aus und fährt weiter geradeaus.
  *
  * @param	Speed   Die Fahrgeschwindigkeit
  * @return	            Kein Rückgabewert(void)
  *
  */
void Ausweichen(uint16_t Speed)
{
    sei();
    /*~~~~~~~~~~*/
    int pos, i;
    int posmarker;
    /*~~~~~~~~~~*/
    TextAusgabe("Vor Ping");
    TextAusgabe(CR);
    posmarker = 0;
    Ping(20);
    TextAusgabe("Nach PING");
    TextAusgabe(CR);
    for (pos = 0; pos < 1000; pos++)
    {
        TextAusgabe("In der ersten For-schleife");
        TextAusgabe(CR);
        /* 1000 = die maximale Entfernung */
        _delay_us(10);
        if ((ACSR & (1 << ACI)) != 0)
        {
            TextAusgabe("Im ersten if");
            TextAusgabe(CR);
            /* Wenn Register ACI von ACSR nicht gesetzt ist dann.. */
            if (posmarker == 0)
            {
                TextAusgabe("Im zweiten if");
                TextAusgabe(CR);
                posmarker = pos;
            }	/* Wenn posmarker = 0 ist dann pos und posmarker gleichsetzen */
        }
        TextAusgabe("Vor ACSR");
        ACSR |= (1 << ACI); /* Das Bit ACI setzen. Damit es durch einen Interrupt gel�scht werden kann */
    }

    if (posmarker < 200)
    {
        TextAusgabe("Im dritten if");
        TextAusgabe(CR);
        /* Wenn ein Hinderniss im Bereich von 200 ist */
        StatusLED(Rot); /* StatusLed leuchtet Rot */
        Motor(BREAK, BREAK, 0, 0);		/* Motor kurz anhalten */
        Motor(FWD, BWD, 0, 255);		/* Linkes Rad vorw�rts und Rechtes R�ckw�rts(Ausweichen) */
    }
    else
    {
        TextAusgabe("Im else");
        TextAusgabe(CR);
        StatusLED(Gruen);				/* LED Gr�n */
        Motor(FWD, FWD, Speed, Speed);	/* Motoren f�hrt geradeaus */

        for (i = 0; i < 100; i++)
        {
            TextAusgabe("Im zweiten for");
            TextAusgabe(CR);
            _delay_ms(1);
        }	/* kurze Pause */
    }
}
コード例 #10
0
ファイル: away.cpp プロジェクト: BGCX261/znc-msvc-svn-to-git
	virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage)
	{
		Ping();
		if (m_bIsAway)
			Back();

		return(CONTINUE);
	}
コード例 #11
0
/* MakeBulkPacket - creates a bulkread packet based on the ping results.
 *    It only needs to be called once because the packet will never change.
 *    If the user wishes to use bulkread, this function must be called first.
 */
void DarwinController::MakeBulkPacket(unsigned char *BulkReadTxPacket){

    int number = 0;

    BulkReadTxPacket[0] = 0xFF;
    BulkReadTxPacket[1] = 0xFF;
    BulkReadTxPacket[ID] = 0xFE;
    BulkReadTxPacket[INSTRUCTION] = 0x92;
    BulkReadTxPacket[PARAMETER] = 0x0;
    
    if(Ping(0xC8, 0)){
        BulkReadTxPacket[PARAMETER+3*number+1] = 30; //length
        BulkReadTxPacket[PARAMETER+3*number+2] = 0xC8; // ID_CM
        BulkReadTxPacket[PARAMETER+3*number+3] = 24; //P_DXL_POWER
        number++;
    }

    if(Ping(70, 0)){
        BulkReadTxPacket[PARAMETER+3*number+1] = 10;    // length
        BulkReadTxPacket[PARAMETER+3*number+2] = 0x70;  // ID_L_FSR
        BulkReadTxPacket[PARAMETER+3*number+3] = 0x1A;  // start address P_FSR1_L
        number++;
    }

    if(Ping(0x6F, 0)){
        BulkReadTxPacket[PARAMETER+3*number+1] = 10;     // length
        BulkReadTxPacket[PARAMETER+3*number+2] = 0x6F;   // id ID_R_FSR
        BulkReadTxPacket[PARAMETER+3*number+3] = 0x1A;   // start address P_FSR1_L
        number++;
    }
    
    for(int id = 1; id < 21; id++){ //NUMBER OF JOINTS = 20
       
       BulkReadTxPacket[PARAMETER+3*number+1] = 23;  // length
       BulkReadTxPacket[PARAMETER+3*number+2] = id; // id
       BulkReadTxPacket[PARAMETER+3*number+3] = 26;  // start at CCW_COMPLIANCE_MARGIN
       number++;
        
    }

    BulkReadTxPacket[LENGTH]          = (number * 3) + 3;  

    int length = BulkReadTxPacket[LENGTH] + 4;
    BulkReadTxPacket[length - 1] = CalculateChecksum(BulkReadTxPacket);

}
コード例 #12
0
LRESULT nsPluginInstance::ProcessMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
		case WM_MOVE:
			// Update trap mouse if required
			UpdateTrapMouse();
			return 0;

		case WM_SIZE:
			// Update trap mouse if required
			UpdateTrapMouse();

			// Inform that the window size has been changed
			FrontendImpl::OnSize();
			return 0;

		case WM_PAINT:
			// Let the frontend draw into it's window
			FrontendImpl::OnDraw();

			// Ping
			Ping();
			return 0;

		// Drag and drop of files
		case WM_DROPFILES:
		{
			// Get dropped filenames. Because there's no way - without extreme overhead :) - to check whether
			// we really need to use Unicode or ASCII is quite enough, we always use Unicode just to be sure.
			const uint32 nNumOfFiles = DragQueryFileW(reinterpret_cast<HDROP>(wParam), 0xFFFFFFFF, static_cast<LPWSTR>(nullptr), 0);
			if (nNumOfFiles) {
				// Create the file list
				PLCore::Array<PLCore::String> lstFiles;
				lstFiles.Resize(nNumOfFiles);
				for (uint32 i=0; i<nNumOfFiles; i++) {
					// Get the length of the string (+1 for \0)
					const UINT nSize = DragQueryFileW(reinterpret_cast<HDROP>(wParam), i, nullptr, 0) + 1;

					// Create the string and fill it
					wchar_t *pszFile = new wchar_t[nSize];
					DragQueryFileW(reinterpret_cast<HDROP>(wParam), i, pszFile, nSize);

					// Store the string (the PL string takes over the control)
					lstFiles[i] = PLCore::String(pszFile, false, nSize - 1);
				}

				// Inform the frontend
				FrontendImpl::OnDrop(lstFiles);
				return 0;
			}
		}

		default:
			break;
	}

	return DefWindowProc(hWnd, msg, wParam, lParam);
}
コード例 #13
0
void SubsonicService::Login()
{
  // Forget session ID
  network_->setCookieJar(new QNetworkCookieJar(network_));
  // Forget login state whilst waiting
  login_state_ = LoginState_Unknown;
  // Ping is enough to check credentials
  Ping();
}
コード例 #14
0
ファイル: turret.cpp プロジェクト: suXinjke/HalfPayne
//
// This search function will sit with the turret deployed and look for a new target. 
// After a set amount of time, the barrel will spin down. After m_flMaxWait, the turret will
// retact.
//
void CBaseTurret::SearchThink(void)
{
	// ensure rethink
	SetTurretAnim(TURRET_ANIM_SPIN);
	StudioFrameAdvance( );
	pev->nextthink = gpGlobals->time + 0.1;

	if (m_flSpinUpTime == 0 && m_flMaxSpin)
		m_flSpinUpTime = gpGlobals->time + m_flMaxSpin;

	Ping( );

	// If we have a target and we're still healthy
	if (m_hEnemy != NULL)
	{
		if (!m_hEnemy->IsAlive() )
			m_hEnemy = NULL;// Dead enemy forces a search for new one
	}


	// Acquire Target
	if (m_hEnemy == NULL)
	{
		Look(TURRET_RANGE);
		m_hEnemy = BestVisibleEnemy();
	}

	// If we've found a target, spin up the barrel and start to attack
	if (m_hEnemy != NULL)
	{
		m_flLastSight = 0;
		m_flSpinUpTime = 0;
		SetThink(&CBaseTurret::ActiveThink);
	}
	else
	{
		// Are we out of time, do we need to retract?
 		if (gpGlobals->time > m_flLastSight)
		{
			//Before we retrace, make sure that we are spun down.
			m_flLastSight = 0;
			m_flSpinUpTime = 0;
			SetThink(&CBaseTurret::Retire);
		}
		// should we stop the spin?
		else if ((m_flSpinUpTime) && (gpGlobals->time > m_flSpinUpTime))
		{
			SpinDownCall();
		}
		
		// generic hunt for new victims
		m_vecGoalAngles.y = (m_vecGoalAngles.y + 0.1 * m_fTurnRate);
		if (m_vecGoalAngles.y >= 360)
			m_vecGoalAngles.y -= 360;
		MoveTurret();
	}
}
コード例 #15
0
HRESULT PixelLightCtrl::OnDrawAdvanced(ATL_DRAWINFO &di)
{
	// Let the frontend draw into it's window
	FrontendImpl::OnDraw();

	// Ping
	Ping();

	// Done
	return S_OK;
}
コード例 #16
0
ファイル: unpc.c プロジェクト: RaphaelJ/Cours-2e-annee
int Interpreteur( char *Buffer, struct Global *g)
{
  char arg0[80],arg1[80],arg2[80],arg3[80],arg4[80] ;
  int rc ;
  bzero(arg0,sizeof(arg1));
  bzero(arg1,sizeof(arg1));
  bzero(arg2,sizeof(arg2));
  bzero(arg3,sizeof(arg3));
  bzero(arg4,sizeof(arg4));
  fprintf(stderr,"Interpreteur ;") ;
  sscanf(Buffer,"%s %s %s %s %s\n",arg0,arg1,arg2,arg3,arg4) ;
  fprintf(stderr,"arg0 %s \n",arg0 ) ;

  /* ATTENTIO? NE PAS OUBLIER ELSE SINON ERREUR DE SYTAXE */
  if (strcmp(arg0,"connexion")==0)  rc=Connexion(Buffer,arg1,arg2,arg3, arg4,g) ;
  else 
  if (strcmp(arg0,"ip")==0 &&( strcmp(arg1,"address")==0) ) rc=IpAddress(Buffer,arg1,arg2,arg3, arg4,g) ;
  else
  if (strcmp(arg0,"netmask")==0 ) rc = Netmask(Buffer,arg1,arg2,arg3, arg4,g) ;
  else 
 if (strcmp(arg0,"gateway")==0 ) rc = Gateway(Buffer,arg1,arg2,arg3, arg4,g) ;
  else
 if (strcmp(arg0,"dns")==0 ) rc = Dns(Buffer,arg1,arg2,arg3, arg4,g) ;
 else
 if (strcmp(arg0,"ports")==0 ) rc = Ports(Buffer,arg1,arg2,arg3, arg4,g) ;
 else
 if (strcmp(arg0,"ping")==0 ) rc = Ping(Buffer,arg1,arg2,arg3, arg4,g) ;
 else
 if (strcmp(arg0,"send")==0 ) rc = Send(Buffer,arg1,arg2,arg3, arg4,g) ;
 else
 if (strcmp(arg0,"bind")==0)  rc = Bind(Buffer,arg1,arg2,arg3, arg4,g) ;
 else
 if (strcmp(arg0,"nslookup")==0 )  rc= NsLookup(Buffer,arg1,arg2,arg3, arg4,g) ;
 else
 if (strcmp(arg0,"waitreceive")==0 ) rc=WaitReceive(g) ;
 else
 if (strcmp(arg0,"read")==0) rc = LireMessage( g ) ;
 else
 if (strcmp(arg0,"exit")==0) exit(0);
 else
 if (strcmp(arg0,"ipconfig")==0) rc = AfficherParametres( g ) ;
 else
 if (strcmp(arg0,"help")==0) rc = Help() ;
 else
 if (Blanc1013(Buffer))
    {
     fprintf(stderr,"Ligne vide \n" ) ;
     rc =  1 ;
    }
 else
    rc = 0 ;
 fprintf(stderr,"fin Interpeteur\n") ;
 return(rc) ;
}
コード例 #17
0
ファイル: arping.c プロジェクト: Moteesh/reactos
int wmain(int argc, LPWSTR argv[])
{
    UINT Count;
    LARGE_INTEGER PerformanceCounterFrequency;

    PingCount = 4;
    Timeout = 1000;
    hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);

    UsePerformanceCounter = QueryPerformanceFrequency(&PerformanceCounterFrequency);

    if (UsePerformanceCounter)
    {
        /* Performance counters may return incorrect results on some multiprocessor
           platforms so we restrict execution on the first processor. This may fail
           on Windows NT so we fall back to GetCurrentTick() for timing */
        if (SetThreadAffinityMask (GetCurrentThread(), 1) == 0)
            UsePerformanceCounter = FALSE;

        /* Convert frequency to ticks per millisecond */
        TicksPerMs.QuadPart = PerformanceCounterFrequency.QuadPart / 1000;
        /* And to ticks per microsecond */
        TicksPerUs.QuadPart = PerformanceCounterFrequency.QuadPart / 1000000;
    }
    if (!UsePerformanceCounter)
    {
        /* 1 tick per millisecond for GetCurrentTick() */
        TicksPerMs.QuadPart = 1;
        /* GetCurrentTick() cannot handle microseconds */
        TicksPerUs.QuadPart = 1;
    }

    if (!ParseCmdline(argc, argv) || !Setup())
    {
        return 1;
    }

    FormatOutput(IDS_ARPING_TO_FROM, TargetIP, SourceName);

    Count = 0;
    while (Count < PingCount || NeverStop)
    {
        Ping();
        Count++;
        if (Count < PingCount || NeverStop)
            Sleep(Timeout);
    }

    Cleanup();

    FormatOutput(IDS_ARPING_STATISTICS, Sent, Received);

    return 0;
}
コード例 #18
0
ファイル: main.c プロジェクト: finaldie/final_test
int  main(int  argc, char* argv[])
{
    max_iteration = abs(atoi(argv[1]));
    iter = 1;
    if (setjmp(Main) == 0)
        Ping();
    if (setjmp(Main) == 0)
        Pong();
    longjmp(PointA, 1);      

    return 0;
}
コード例 #19
0
void CheckInternetConnection(bool starting) {
    static uint32_t lastCheckClock = millis();

    if((millis() - lastCheckClock) >= CHECK_CONNECTION_TIME * CLOCKS_PER_SEC || starting) {
        static byte ip[sizeof PING_DNS];
        memcpy_P(&ip[0], &PING_DNS[0], sizeof ip);

        InSession.InternetConnection = Ping(ip);

        lastCheckClock = millis();
    }
}
コード例 #20
0
ファイル: kroleservereyes.cpp プロジェクト: github188/yol
BOOL KRoleServerEyes::Activate()
{
	BYTE*               pbyData             = NULL;
	size_t              nPackLen            = 0;
	BYTE                byProtocol          = 0;
	PROTOCOL_FUNCTION   ProtocolFunction    = NULL;
	time_t              nTimeNow            = time(NULL);

	while (true)
	{
		pbyData = (BYTE*)m_Stream.GetPack(nPackLen);

		if (!pbyData)
		{
			break;
		}

		byProtocol = *pbyData;

		ProtocolFunction = m_ProtocolFunctions[byProtocol];

		if (ProtocolFunction)
		{
			(this->*ProtocolFunction)(pbyData, nPackLen);
		}
		else
		{
			QLogPrintf(LOG_DEBUG, "Invalid FSEyes protocol : %d\n", byProtocol);
		}

		m_Stream.PopPack();
	}

	if (nTimeNow >= m_nNextPingTime)
	{
		Ping();
		m_nNextPingTime = nTimeNow + 20;
	}

	//if (nTimeNow > m_nNextSendPlayerCountTime)
	//{
	//	SendPlayerCount();
	//	m_nNextSendPlayerCountTime = nTimeNow + 5;
	//}

	if (nTimeNow > m_nNextSendCustomInfoTime)
	{
		SendCustomInfo();
		m_nNextSendCustomInfoTime = nTimeNow + 10;
	}
	return TRUE;
}
コード例 #21
0
ファイル: C4Network2IO.cpp プロジェクト: 772/openclonk
bool C4Network2IO::Ping()
{
    bool fSuccess = true;
    // ping all connections
    for (C4Network2IOConnection *pConn = pConnList; pConn; pConn = pConn->pNext)
        if (pConn->isOpen())
        {
            C4PacketPing Ping(pConn->getInPacketCounter(), pConn->getOutPacketCounter());
            fSuccess &= pConn->Send(MkC4NetIOPacket(PID_Ping, Ping));
            pConn->OnPing();
        }
    return fSuccess;
}
コード例 #22
0
void jumpwireIo::loop()
{ 
  if(ws_status == 4){  //Wifi error
    ws_connect();
  }else if(ws_status == 3){ //Websocket error
    httpConnect();
  }else if(ws_status == 2){ //Waiting for an incomming message
    parseWebsocket();
  }
  if(millis() - pingtimer > 55000){ //ping every 55 sec.
    pingtimer = millis();
    Ping();
  }
}
コード例 #23
0
ファイル: main.cpp プロジェクト: CCJY/coliru
int main()
{
    std::cout << "Ready… Set… Go!\n";
    
    std::thread Ping(ping);
    std::thread Pong(pong);
    
    Ping.join();
    Pong.join();
    
    std::cout << "Done!\n";
    
    return 0;
}
コード例 #24
0
void CWatchdogMngr::OnQuit()
{
	CSimpleTimer t ;

	Ping(); //to make sure that prepare_for_reboot.sh has time to run
	systemf_to( ON_QUIT_DELAY, NIVIS_FIRMWARE "prepare_for_reboot.sh&"  );
	LOG("Waiting[%u seconds] for prepare_for_reboot.sh",ON_QUIT_DELAY) ;

	int nTimeLeftToPing = ON_QUIT_DELAY;

	if (FileIsExecutable(FTP_SCRIPT))
	{
		nTimeLeftToPing = ON_QUIT_DELAY_FTP_LOGS;
	}

	t.SetTimer( nTimeLeftToPing) ;
	while( ! t.IsSignaling() )
	{
		Ping() ;
		Sleep() ;
	}
	Ping() ;
	systemf_to( 20, "log2flash 'WTD: Finished running quit procedure.'&");
}
コード例 #25
0
//
// This search function will sit with the turret deployed and look for a new target. 
// After a set amount of time, the barrel will spin down. After m_flMaxWait, the turret will
// retact.
//
void CBaseTurret::SearchThink(void)
{
	// ensure rethink
	SetActivity( (Activity)ACT_TURRET_OPEN_IDLE );

	StudioFrameAdvance( );
	SetNextThink( gpGlobals->curtime + 0.1f );

	Ping( );

	// If we have a target and we're still healthy
	if (GetEnemy() != NULL)
	{
		if (!GetEnemy()->IsAlive() )
			SetEnemy( NULL );// Dead enemy forces a search for new one
	}

	// Acquire Target
	if (GetEnemy() == NULL)
	{
		GetSenses()->Look(TURRET_RANGE);
		SetEnemy( BestEnemy() );
	}

	// If we've found a target, spin up the barrel and start to attack
	if (GetEnemy() != NULL)
	{
		m_flLastSight = 0;
		SetThink(ActiveThink);
	}
	else
	{
		// Are we out of time, do we need to retract?
 		if (gpGlobals->curtime > m_flLastSight)
		{
			//Before we retrace, make sure that we are spun down.
			m_flLastSight = 0;
			SetThink(Retire);
		}
		
		// generic hunt for new victims
		m_vecGoalAngles.y = (m_vecGoalAngles.y + 0.1 * m_iBaseTurnRate);
		if (m_vecGoalAngles.y >= 360)
			m_vecGoalAngles.y -= 360;

		MoveTurret();
	}
}
コード例 #26
0
void SubsonicService::Login() {
  // Recreate fresh network state, otherwise old HTTPS settings seem to get reused
  network_->deleteLater();
  network_ = new QNetworkAccessManager(this);
  network_->setCookieJar(new QNetworkCookieJar(network_));
  // Forget login state whilst waiting
  login_state_ = LoginState_Unknown;

  if (IsConfigured()) {
    // Ping is enough to check credentials
    Ping();
  } else {
    login_state_ = LoginState_IncompleteCredentials;
    emit LoginStateChanged(login_state_);
  }
}
コード例 #27
0
ファイル: g2node.cpp プロジェクト: Toxic-Lab/DroidG2
void G2Node::OnTimer()
{
    if(System::Since(timestamp_) > ALIVE_TIMEOUT)
    {
        System::LogBas() << "Hub " << myInfo_.endpoint << " timeout. Disconnecting." << std::endl;
        Close();
        DetachMe();
        return;
    }

    if(periodLNI_.Set()) UpdateLNI();

    if(periodQHT_.Set()) UpdateQHT();

    if(periodPing_.Set()) Ping();
}
コード例 #28
0
void CBasicListener::OnReadyRead()
{
    /* Determine the size of the incoming datagram and
       create room for it in a buffer. */
    QByteArray message;
    message.resize(pendingDatagramSize());

    /* Grab the message (and the address that sent it). */
    QHostAddress address;
    readDatagram(message.data(), message.size(), &address);

    /* Decode the JSON we received. */
    bool ok;
    QVariantMap map = QJson::Parser().parse(message, &ok).toMap();

    /* Make sure that there were no errors decoding the JSON and that
       we can read the results without any problems. */
    if(!ok || !map.contains("version") || map["version"].toInt() != Definitions::ProtocolVersion)
    {
        /* We only want to alert the user once. */
        static bool displayed_warning = false;

        if(!displayed_warning)
        {
            QMessageBox::warning(NULL, tr("Warning:"), tr("One of the machines on your network ('%1') is running a different version of NitroShare than this machine (%2). Please ensure both machines are running the latest version of NitroShare.")
                                 .arg(address.toString()).arg(Definitions::Version));
            displayed_warning = true;
        }

        return;
    }

    /* Make sure none of the properties are ending. */
    if(!map.contains("id") || !map.contains("name") ||
            !map.contains("transmission_port") || !map.contains("uptime"))
    {
        qDebug() << "Ping received from" << address.toString() << "is invalid.";
        return;
    }

    /* Next, make sure that this is not one of _our_ packets. */
    if(map["id"] == Settings::GetID())
        return;

    /* Seems like a valid packet. */
    emit Ping(address, map);
}
コード例 #29
0
ファイル: ezSQL.cpp プロジェクト: freem/SMOnline-v1
bool ezSQLConnection::BlockingQuery( ezSQLQuery & QueryData, int WaitTime, bool SetDropIfFail )
{
	m_lLastBlockingID++;
	if ( m_lLastBlockingID > 1000000000 )
		m_lLastBlockingID = 0;
	unsigned long LookingFor = m_lLastBlockingID;
	QueryData.m_ID = m_lLastBlockingID;
	Query ( QueryData );		//Send the query

	QueryData.m_ResultInfo.Reset();

	//Forcefully wait until we get the packet we are looking for.
	//Don't worry, GetResult calls Update which checks to see if
	//if we have been disconnected from the server.

	long TimeToStop = time( NULL ) + WaitTime;

	bool failed = false;

	//m_Socket.blocking = true;
	while ( !GetResult( QueryData, LookingFor, true ) )
	{
		if ( time( NULL ) > TimeToStop )
		{
			failed = true;
			Ping( );
			break;
		}
#if defined(WIN32)
		Sleep(10);
#else
		usleep(10000);
#endif
	}

	//m_Socket.blocking = false;
	if ( !m_bConnected || failed )
	{
		if ( SetDropIfFail )
			for ( unsigned int i = 0; i < m_lReceived.size(); i++ )
				if ( m_lSent[i].m_ID == long(LookingFor) )
					m_lSent[i].m_dropResponce = true;
		return false;
	}

	return true;
}
コード例 #30
0
ファイル: main.c プロジェクト: suborb/zsock
void __APPFUNC__ handlecmds(int cmd)
{
    if (cmd >= 0x87 ) {
	/* On/offline options */
	switch (cmd) {
	case 0x87:
	    _DeviceOffline(HANGUP);
	    printf("Hungup\n");
	    break;
	case 0x88:
	    _DeviceOffline(NOHANGUP);
	    printf("Offline\n");
	    break;
	case 0x89:
	    _DeviceOnline();
	    printf("Turned device online\n");
	}
    } else {
	if (process) { 
	    putchar(7);	/* Beep */
	    return; 
	} else {
	    process=cmd;
	    switch (cmd) {
	    case 0x81:
		Ping();
		break;
	    case 0x82:
		do_netstat();
		break;
	    case 0x83:
		UserConfig();
		break;
	    case 0x84:
		exit(0);
		break;
	    case 0x85:
		device_report();
		break;
	    case 0x86:
		figures();
	    }
	    process=0;
	}
    }
}