Click here to Skip to main content
15,671,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Client routine that works like a charm from an XP computer to another XP computer. When I use the same routine on a Windows 10 system I get an unhandled exception saying " A connection attempt failed because the connected party didn't respond in time.

Imports System.Net.Sockets
Imports System.Text
Class TCPCli
Shared Sub Main()

Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect("", 8000) <---this is the offending line
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
' Do a simple write.
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is anybody there")
networkStream.Write(sendBytes, 0, sendBytes.Length)
' Read the NetworkStream into a byte buffer.
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Output the data received from the host to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine(("Host returned: " + returndata))
If Not networkStream.CanRead Then
Console.WriteLine("cannot not write data to this stream")
If Not networkStream.CanWrite Then
Console.WriteLine("cannot read data from this stream")
End If
End If
End If
' pause so user can view the console output
End Sub

What I have tried:

I've tired several different network configuration set ups. With no success. Do newer bluetooth systems not work with older ones? Can this be over come. The computer I want to compunicate has a rather lengthy program that interfaces my railroad set up.
Updated 13-May-18 21:18pm

1 solution

tcpClient.Connect("", 8000) 
That will try to connect to localhost and not to another system. So you will get the seen error message when the server application is not running on your system.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900