1

I'm following the MSDN tutorial here which details how to make a basic client-server TCP chat program.

I have all the code in place, and it is compiling, however I'm hitting an issue in the socketClient class, when trying to create the new TcpListener object.

The tutorial says to use the line:

mobjClient = New TcpClient("localhost", 5000)

However, on running this, I get the error:

An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.dll Additional information: A non-recoverable error occurred during a database lookup

Playing with the hostname part of the constructor, I get an identical message for the following as parameters. The function call returns the name of the machine correctly.

(System.Net.Dns.GetHostName(), 5000)

I also tried using the IP of the machine, both as 127.0.0.1 and it's actual IP. Using an IP gives a slightly different error of

An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.dll Additional information: An invalid argument was supplied

I also found this link which is someone else using the same tutorial, which supplies complete code.

Phil
  • 167
  • 6

2 Answers2

3

Found a partial solution on this answer

Apparently VS.net is very picky about the fact that the assembly is running on a network location. While the above links problem isn't the same, it's definitely related, as moving the project to the local drive caused the TCPListener to work properly.

I now have other bugs to work out, but I believe they are unrelated. I also could not get his app.config solution to solve my problem. Only by copying to the local disk would the program run.

Community
  • 1
  • 1
Phil
  • 167
  • 6
0

mobjClient As New TcpClient("localhost", 5000)