ZeroEffect
Junior Contributor
Here is what I am trying to do. I am using TCPClient to connect to another application send data and close the connection. Then when more data is is received to reconnect and send data to the same application. I can get this to work once. then I get this message.
This is the code I am using.
My thought is that I shouldn't have to recreate the object everytime I use it. I should be able to just open and close it or am I mistaken.
Thanks for you help,
ZeroEffect
Visual Basic:
Once the socket had been disconnected, you can only reconnect again asynchronously,
and only to a different EndPoint. BeginConnect must be called on a thread
that won't exit until the operation has been completed
This is the code I am using.
Visual Basic:
'This is created in another part of the application
'
Dim groupEP As New IPEndPoint(IPAddress.Any, 20000)
tRemote1 = New TcpClient(groupEP)
'
'This is called from another sub.
'
tRemote1.Client.Connect(strRemotePort1IP, strRemotePort1Port)
tRemote1.GetStream.Write(sendBytes1, 0, sendBytes1.Length)
tRemote1.Client.Disconnect(True)
tRemote1.Client.Shutdown(Net.Sockets.SocketShutdown.Both)
My thought is that I shouldn't have to recreate the object everytime I use it. I should be able to just open and close it or am I mistaken.
Thanks for you help,
ZeroEffect