Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
Imports System.Net.Sockets Imports System.net Imports System.Text Imports System.Net.DnsPermissionAttribute Imports System.Security.Permissions Public Class Form1 Const portNumber As Integer = 5679 Private tcpListener As New TcpListener(CType(Dns.Resolve("LMI111").AddressList(0), IPAddress), portNumber) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Listening must be on the same port that the client is connected on. '"Localhost" string is used when the client and the listener are on the same computer. 'If the listener is listening at a computer that is different from the client, then provide the host name of the computer 'where the listener is listening. 'Comment the previous line and uncomment the following line if you are using Visual Basic .NET (2003). 'Dim tcpListener As New TcpListener(portNumber) tcpListener.Start() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Console.WriteLine("TCP Server is up and waiting for Client connection...") Me.Label1.Text = "TCP Server is up and waiting for Client connection..." ''Accept the pending client connection and return a TcpClient for communication. Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient() ' Console.WriteLine("Connection accepted.") ' Get the data stream. Dim networkStream As NetworkStream = tcpClient.GetStream() ' Read the data stream into a byte array. Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) ' Return the data received from the client to the console. Dim clientdata As String = Encoding.ASCII.GetString(bytes) Me.Label1.Text = "Client sent: " + clientdata Dim responseString As String = "Successfully connected to TCP server." Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString) networkStream.Write(sendBytes, 0, sendBytes.Length) 'Console.WriteLine(("Message Sent by TCP Server /> : " + responseString)) 'Close TcpListener and TcpClient. tcpClient.Close() tcpListener.Stop() ' Console.WriteLine("Exit") 'Console.ReadLine() End Sub End Class