• Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

C# Checking Online Availability with IP and Port

1UP

Member
Code:
using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Net.Sockets;

namespace CSharpCheckingOnlineAvailabilityIPPort

{

  public partial class Form1 : Form

  {

  public Form1()

  {

  InitializeComponent();

  }

  private void btn_CheckServer_Click(object sender, EventArgs e)

  {

  TcpClient logonServer = new TcpClient();

  try

  {

  logonServer.Connect("127.0.0.1", 80); //this is just your loop back and checking to see if port 80 is open swap out for whatever you want

  }

  catch (Exception ex)

  {

   

  }

  if (logonServer.Connected)

  this.Text = "Connected";

  else

  this.Text = "Not connected";

  logonServer.Close();

   

  }

  }

}

Source Code
 
General chit-chat
Help Users
      Chat Bot: Cerberus__11 has posted a new reply in the thread "*NEW* Mod Menu Serendipity v1.0.4".
      Back
      Top