public void TestThatICanPingAnIPAddress() { var pinger = new Pinger(); var result = pinger.DoPing("81.108.106.67"); Assert.IsTrue(result); }
/// <summary> /// Constructor. /// </summary> /// <param name="nameservers">Array of nameserver IP addresses.</param> public HealthResolver(string[] nameservers) { dns = NeonDnsClient.CreateWithCaching(nameservers); pinger = new Pinger(); hostToAddresses = new Dictionary <string, List <IPAddress> >(StringComparer.InvariantCultureIgnoreCase); addressToHealth = new Dictionary <string, bool>(); }
public PingerViewModel() { Pinger = new Pinger(true); _pingCommand = new PingerPingCommand(this); InitPongService(); }
protected override void OnFormClosing(FormClosingEventArgs e) { //Notify.KillAndClose(); ni.Dispose(); CloseAll(); Pinger.Stop(); SettingsWriter w = new SettingsWriter(Settings.Reg); w.Write(total, "TOTAL"); w.Close("Total"); GlobalProperties.Client.Close(); if (Opacity != 0.0) { e.Cancel = true; new Thread(() => { while (Opacity != 0.0) { Invoke((MethodInvoker) delegate { Opacity -= 0.1; }); Thread.Sleep(50); } Invoke((MethodInvoker) delegate { base.OnFormClosing(e); Environment.Exit(0); }); }).Start(); } }
public async Task <(long length, Guid packId, MessageType messageType, Stream data)> ReadMessage() { await readindMessageSemaphore.WaitAsync(); try { long length = reader.ReadInt64(); Guid packId = new Guid(reader.ReadBytes(16)); MessageType type = (MessageType)reader.ReadByte(); logger.LogDebug($"READ ID : {packId} Type : {type}"); if (type == MessageType.PingResponse) { Pinger.SetPing(packId); return(await ReadMessage()); } return(length, packId, type, tcpClient.GetStream().Partial(length)); } catch (Exception ex) { logger.LogWarning(ex, "Error while reading"); ConnectionLost(); throw; } finally { readindMessageSemaphore.Release(); } }
public async Task Basic() { using (var pinger = new Pinger()) { // The loopback address should always answer. Assert.Equal(IPStatus.Success, (await pinger.SendPingAsync("127.0.0.1")).Status); Assert.Equal(IPStatus.Success, (await pinger.SendPingAsync(IPAddress.Parse("127.0.0.1"))).Status); // FRAGILE: // // Verify that the ping times out for an IP address that's very unlikely to have // anything running on it (at least in our test/dev environments). var status = (await pinger.SendPingAsync(IPAddress.Parse("10.227.126.253"))).Status; Assert.True(status == IPStatus.TimedOut || status == IPStatus.DestinationNetworkUnreachable); // The [240.0.0.0/4] subnet is currently reserved and should not // not be routable (and probably never will be). // // NOTE: Note that we don't see [PingExceptions] on OS/X, so we're not // going to run this test on OS/X. if (!NeonHelper.IsOSX) { await Assert.ThrowsAsync <PingException>(async() => await pinger.SendPingAsync("240.0.0.0")); await Assert.ThrowsAsync <PingException>(async() => await pinger.SendPingAsync(IPAddress.Parse("240.0.0.0"))); } } }
/// <summary> /// Force the communicator to sever it's connection. /// </summary> public void Disconnect() { lock (this) { try { if (pinger != null) { pinger.Running = false; } if (keepAliveTimer != null) { keepAliveTimer.Dispose(); } if (session != null) { session.Disconnect_async(new Disconnect_Callback()); } if (router != null) { router.destroySession_async(new RouterDestroySession_Callback()); } if (logger != null) { logger.Close(); } DestroyCommunicator(); } catch (System.Exception e) { if (logger != null) { logger.Error( "Unexpected error in the Disconnect() method: {0}", e); } else { Console.Error.WriteLine(e); } } finally { Connected = false; pinger = null; keepAliveTimer = null; session = null; router = null; factory = null; tankList = null; tankListNeedsRefresh = true; // weaponList = null; logger = null; } } }
public Start() { Mock.Get(_connection).Setup(m => m.Sender).Returns(_sender); Mock.Get(_task).Setup(t => t.Run(It.IsAny <Action>())).Callback <Action>((action) => action.Invoke()); _args = new ConnectionStartedEventArgs(_tokenSource.Token); _pinger = new Pinger(_task, _thread, _value, _milisecondsIntervalTime); }
/// <summary> /// Log into the server synchronously, which means it will block until it receives /// a response. /// </summary> /// <param name="user">Username to login with.</param> /// <param name="password">Password for the user.</param> /// <param name="version">Version of the client.</param> /// <param name="callback">Callback, called when the login finishes.</param> /// <exception cref="Network.Exceptions.LoginFailedException"> /// Thrown if the login failed.</exception> public void Login(string user, string password, VTankObject.Version version) { try { session = MainSessionPrxHelper.uncheckedCast( factory.VTankLogin(user, password, version)); pinger = new Pinger(session); if (KeepAlive) { keepAliveTimer = new Timer(new TimerCallback(OnKeepAlive), null, KeepAliveInterval, KeepAliveInterval); } } catch (Exceptions.PermissionDeniedException e) { logger.Info("Login() PermissionDeniedException: {0}", e.reason); throw new LoginFailedException(e.reason); } catch (Ice.Exception e) { logger.Error("Login() Ice.Exception: {0}", e); throw new UnknownException("Cannot connect to the server."); } catch (System.Exception e) { logger.Error("Login() System.Exception: {0}", e); throw new UnknownException("Cannot connect to the server."); } }
private void StartCheckerForPings() { _lastPing = DateTime.Now.Ticks; _pingFailCount = 0; _pinger = new Pinger(Id); _pingTimer = new Timer(this.CheckForRecentPing, this, PingIntervalMilliseconds, PingIntervalMilliseconds); }
public RemotePoint(TcpClient client, ILoggerFactory factory) { Pinger = new Pinger(SendMessage, factory.CreateLogger <Pinger>()); reader = new BinaryReader(client.GetStream(), Encoding.UTF8, true); tcpClient = client; logger = factory.CreateLogger <RemotePoint>(); }
/// <summary> /// Force the communicator to sever it's connection. /// </summary> public void Disconnect() { lock (this) { try { Connected = false; if (pinger != null) { pinger.Running = false; } if (keepAliveTimer != null) { keepAliveTimer.Dispose(); } if (timerThread != null) { timerThread.Interrupt(); } if (session != null) { session.destroy_async(new Destroy_Callback()); } if (router != null) { router.destroySession_async(new GameRouterDestroySession_Callback()); } if (logger != null) { logger.Close(); } DestroyAdapter(); DestroyCommunicator(); } catch (System.Exception e) { logger.Error( "Unexpected error in the Disconnect() method: {0}", e); } finally { pinger = null; keepAliveTimer = null; session = null; sessionOneway = null; router = null; auth = null; timerThread = null; logger = null; } } }
private void btnPing_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.SelectMenu(btnPing); Pinger ping = new Pinger(_pingPanel); this.splitContainer.Panel2.Controls.RemoveAt(0); this.splitContainer.Panel2.Controls.Add(_pingPanel); }
static void Main(string[] args) { Pinger p = new Pinger(); p.startNewThread(); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
protected StdSocket(ILoggerFactory loggerFactory, string name, string host, int port, ProtocolType protocolType) { _loggerFactory = loggerFactory; _instanceName = name; _host = host; _port = port; ProtocolType = protocolType; _pinger = new Pinger(_loggerFactory, _host, _instanceName); //ToDo }
/// <summary> /// Join the game server. Once active, this officially joins the game. /// </summary> /// <param name="key">Key given by the main communicator after calling /// RequestJoinGameServer().</param> /// <returns>True if successful; false otherwise.</returns> public bool JoinServer(string key) { bool result = false; try { lock (this) { adapter.activate(); ClientEventCallbackPrx clientCallback = ClientEventCallbackPrxHelper. uncheckedCast(adapter.createProxy(clientIdentity)); ClockSynchronizerPrx clockCallback = ClockSynchronizerPrxHelper. uncheckedCast(adapter.createProxy(clockIdentity)); session = auth.JoinServer(key, clockCallback, clientCallback); // Configure the proxy. session = GameInfoPrxHelper.uncheckedCast( session.ice_router(router)); sessionOneway = GameInfoPrxHelper.uncheckedCast( session.ice_oneway()); Refresh(); timerThread = new Thread(new ThreadStart(TimeTicker)); timerThread.Start(); if (KeepAlive) { keepAliveTimer = new Timer(new TimerCallback(OnKeepAlive), null, KeepAliveInterval, KeepAliveInterval); } pinger = new Pinger(session); } result = true; } catch (Ice.IllegalIdentityException e) { logger.Error("JoinServer() No callbacks registered: {0}", e); throw new InvalidValueException("You must register callbacks first."); } catch (Exceptions.PermissionDeniedException e) { logger.Info("JoinServer() Failed (permission denied): {0}", e.reason); } catch (Ice.Exception e) { logger.Error("JoinServer() Ice.Exception: {0}", e); } catch (System.Exception e) { logger.Error("JoinServer() System.Exception: {0}", e); } return(result); }
void threadProc() { Pinger p = new Pinger(); while (true) { p.ExecEndless(); } }
public void Should_return_a_pong_to_the_pinger() { var pinger = new Pinger(); var ponger = new Ponger(); pinger.Ping(ponger.PongChannel); ponger.Pinged.IsAvailable(1.Seconds()).ShouldBeTrue(); pinger.Ponged.IsAvailable(1.Seconds()).ShouldBeTrue(); }
public TraceRouteControl(ref Pinger _pinger) { InitializeComponent(); CloseWindowCommand = new Command(Close); pinger = _pinger; host = _pinger.UpdateHost(); hostNameLabel.Content = host.HostName; traceView.ItemsSource = TraceReplies; syncCtx = SynchronizationContext.Current; }
public void Should_return_a_pong_to_the_pinger() { var pinger = new Pinger(); var ponger = new Ponger(); pinger.Ping(ponger.PongChannel); ponger.Pinged.WaitUntilCompleted(1.Seconds()).ShouldBeTrue(); pinger.Ponged.WaitUntilCompleted(1.Seconds()).ShouldBeTrue(); }
private async void SendPing(string ip) { btPing.Enabled = false; btPing.Text = "Pinging..."; var resp = await Pinger.PingHost(currentAddress.ToStringWithoutMask()); btPing.Enabled = true; btPing.Text = "Ping"; MessageBox.Show(resp); }
public void ping_until_connected() { var completed = new ManualResetEvent(false); using (var pinger = new Pinger(new StubSender(5), 50.Milliseconds(), () => completed.Set())) { completed.WaitOne(1.Seconds()) .ShouldBeTrue(); } }
/// <summary> /// When URL changes stops and restarts everything. /// </summary> private void UrlSelector_URLChanged(object sender, string e) { Pinger.Stop().ContinueWith((previousTask) => { _dispatcher.Invoke(new Action(() => { PingManipulator.Reset(); Graph.Reset(); Display.Reset(); Pinger.Start(e); })); }); }
public void DoStart() { StopBtn.IsEnabled = true; StartBtn.IsEnabled = false; HostNameBox.IsEnabled = false; IntervalBox.IsEnabled = false; WarningBox.IsEnabled = false; TimeoutBox.IsEnabled = false; PacketSizeBox.IsEnabled = false; Pinger = new Pinger(PingHost); Pinger.Start(); }
public async Task <Dictionary <string, bool> > CheckAllSystems() { var systemDescriptors = await _systemService.GetAll(); var resultDictionary = new Dictionary <string, bool>(); systemDescriptors.ForEach(d => { resultDictionary.Add(d.SystemName, Pinger.Ping($"{d.Address}", d.Port)); }); return(resultDictionary); }
public override void OnDisconnect() { if (Server != null) { Program.MainForm.LogAppend($"Server disconnected: {Server.Name}"); Server.SetConnection(null); Server = null; } Pinger.Remove(this); }
private static void StartPing() { for (int i = 0; i < numPing; i++) { PingReply reply = new Pinger(Reference.command[1].ToLower()).Ping(); if (reply != null) { table.AddRow($"{reply.Status}", $"{reply.RoundtripTime}ms", $"{reply.Address}"); } } table.Write(); }
/// <summary> /// /// </summary> protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); Trace.Listeners.Add(new TextWriterTraceListener(Server.MapPath(Resources.Internals.LogFile))); Trace.AutoFlush = true; Pinger p = new Pinger(); // start pinging users }
private void Init() { Player = new Player() { Socket = this, Character = null }; Server.Instance.AddPlayer(Player); SendHandshake(Constants.MAPLE_VERSION, Constants.MAPLE_PATCH_LOCATION, Constants.MAPLE_LOCALE); SendMemoryRegions(); Pinger.Add(this); }
public PingPongLatencyTest() { InitHistogram(); pongBarrier = pongBuffer.NewBarrier(); pinger = new Pinger(pingBuffer, ITERATIONS, PAUSE_NANOS); pingProcessor = new BatchEventProcessor <ValueEvent>(pongBuffer, pongBarrier, pinger); pingBarrier = pingBuffer.NewBarrier(); ponger = new Ponger(pongBuffer); pongProcessor = new BatchEventProcessor <ValueEvent>(pingBuffer, pingBarrier, ponger); pingBuffer.AddGatingSequences(pongProcessor.Sequence); pongBuffer.AddGatingSequences(pingProcessor.Sequence); }
public RawSocketConnection(SocketData connection, IWampStreamingMessageParser <TMessage> parser, TimeSpan?autoPingInterval) { mParser = parser; mConnection = connection.ConnectionContext; mMaxAllowedMessageSize = connection.Handshake.MaxMessageSizeInBytes; mPinger = new Pinger(this); mPingPongHandler = new PingPongHandler(mLogger, mPinger, autoPingInterval); }
public PingPongLatencyTest() { InitHistogram(); pongBarrier = pongBuffer.NewBarrier(); pinger = new Pinger(pingBuffer, ITERATIONS, PAUSE_NANOS); pingProcessor = new BatchEventProcessor<ValueEvent>(pongBuffer, pongBarrier, pinger); pingBarrier = pingBuffer.NewBarrier(); ponger = new Ponger(pongBuffer); pongProcessor = new BatchEventProcessor<ValueEvent>(pingBuffer, pingBarrier, ponger); pingBuffer.AddGatingSequences(pongProcessor.Sequence); pongBuffer.AddGatingSequences(pingProcessor.Sequence); }