TCPSocket Errors 22 & 102

I have a console application running a few threads. ICP, AutoDiscovery, and a ServerSocket. Everything is running smoothly. The server socket creates the TCPSockets with my code as is expected.

The problem is when I attempt to send a message with any connected TCPSocket. The receiving device throws the error 22 and the sending device immediately throws the error 102 (which is that the socket is disconnected). The receiving device never receives the message.

I have set this up as many different ways as I can, even using EasyTCPSockets, but I’m still getting those same errors.

Any help would be greatly appreciated.

An interesting update on this. The device that does not initiate the connection is able to send. It is the device that initiates the connection that, when sending, kills the connection.

What I had to do on a project was ignore the error 22. I’d have to dig through the project to figure out what all I did but I think on the server side I had to keep a reference to the socket that the connection came in on otherwise once it went out of scope it would close the connection.

Hey, Bob. Good to hear from you out there! Yeah. The 22 doesn’t bother me, it’s the 102 from the other machine that is the issue. I have everything scoped globally. I’m thinking of making two TCPSockets for each connection. One device connects and is assigned a socket by the ServerSocket, I then send right back to the sending machine and connect through their ServerSocket. Then I’ve at least got one socket for each device on the network that I can send through. Seems too bulky, but it’s going to take me less time to do that than figure this sucker out.

Good to hear from you, and thanks!

Unless your client is talking to multiple machines (and not just the server) you can get by with a single socket on the client and the ServerSocket on the server (duh). I’ve got a project that does this and I double checked the code and I’m not doing anything special with the sockets.

On the Server I have a ‘messages’ class that has the remote IP address as a property and then I cycle through the ServerSocket ActiveConnections.

dim aroTCPSockets() as TCPSocket = m_oServerSocket.ActiveConnections for i as integer = 0 to aroTCPSockets.Ubound if aroTCPSockets(i).BytesLeftToSend = 0 then clsClientSocket.SendNextMessage clsClientSocket(aroTCPSockets(i)) end next

Obviously it’s up the client to keep the connection active. If it loses connection with the server it immediately tries to re-establish the connection.

If the client gets the disconnect error we immediately try to reconnect. Before we send a message we ask if it’s still connected (and if not try to reconnect).

Not sure that this all helps but it gives me an idea for a training video (or three).

Bob, this might be a little incite into this. Both (all) of the console programs have ServerSockets. Using AutoDiscovery, when a new guy comes on board through AutoDiscovery, that app gets all the ip’s on AutoDiscovery, initiates a call all the other ServerSockets. Everything connects properly, it’s the communication that’s the issue.

It is in this case that the only the TCPSocket on the application that initiates the call to the other ServerSocket can receive. I’ve tried creating two links between each device, and it works but it drops sockets like crazy and is very bulky.

Do you think the problem might be that both sides have ServerSockets?

I don’t think so.

I would break down into simpler, smaller projects and figure out what’s happening. Sometimes the bigger more complex projects have some unwanted crap going on that obscures the real issue. Get it working the simple model first and then replicate it in the bigger project. I actually do this a lot (and they become projects for training videos at some point).

Hi Gary McGuire,

I found this old post. I a simple listning app I try to listen the data send by another app.
I know the data that I will recieve over TCPsocket comes from a foreign application and it might be contain a lot of special characters.

My question did you found any solution for error 102 ?

[quote=331569:@Marc van Buel]Hi Gary McGuire,

I found this old post. I a simple listning app I try to listen the data send by another app.
I know the data that I will recieve over TCPsocket comes from a foreign application and it might be contain a lot of special characters.

My question did you found any solution for error 102 ?[/quote]
There is no “solution” to error 102 or 22. They both indicate a disconnect from the other side. Whether it’s that they called the Close method or that there was network interference, or whatever. Just have the client reconnect.