The first line is some error checking, If we can read the stream, then we have a connection, as well as if we can write to it. If everything is fine, we move onto the next piece.
We create a byte array and encode the text “Is anybody there” into bytes for transmission across the stream.

The first line is for dimming the byte as a buffer with the size of the recieve buffer, We then read any data trasmitted across the stream and store it into the byte buffer.

The data is then encoded on the third line back into ASCII so it would represent number and letters.
We then write to the console the words “Host Returned:” and any text the server was responded with.

Else
If Not networkStream.CanRead Then
Console.WriteLine("cannot not read data to this stream")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
Console.WriteLine("cannot write data from this stream")
tcpClient.Close()
End If
End If
End If
Console.ReadLine()
End Sub
End Class

The final lines of code are self explanatory, If we cannot read the data stream, then there must be a error and notify the user then shutdown the connection. The same if we cannot write to the stream, notify the user and shut the connection

The final “Console.ReadLine()” is to let the pause the console so the user can view the message