TCPSocket Dropping Connection With Communication

I have a console app in which I discover The other computers on the network using AutoDiscovery. I put those IP address in an array.

Next I create a ServerSocket which creates the necessary TCPsockets without any issues. Next comes an array, Dim’d to the number of IP addresses in which I created an instance of my TCPSocket, connects to the server socket on the other device. It connect successfully. The scope of the ServerSocket and the array of TCPSockets is global.

Here is my problem. After checking to see that the TCPSocket.IsConnected = True, I send a message and the receiving device throws a TCPSocket error number 22. The sending machine throws error number 102 (lost connection). The message is never received.

I am doing this on a Mac & a PC, but the errors are the same for the sending and receiving device either way.

What little hair I have seem to be falling out. Anyone have any ideas?

I think you may have misunderstood how ServerSocket is intended to be used. ServerSocket is only for use on a server that has to listen for multiple clients connecting TO it - as each connection is established, ServerSocket is immediately ready to receive a connection from another client.

For your situation, you can forget about using ServerSocket and just create an array of TCPSockets, one for each remote computer you are going to contact. That should work as expected.

It sounds like you are incorrectly calling TCPsocket.Listen. Such sockets will connect but error 22 when written to.
Your ServerSocket should be listening, but your spawned sockets should not.