C# Checking Online ...
 
Notifications
Clear all

C# Checking Online Availability with IP and Port


1UP
Posts: 25
 1UP
Topic starter
(@1UP)
Eminent Member
Joined: 10 years ago
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

Reply
Name of the Video Game, and any other Tags