0

I have a TCP Socket Client (using the Socket Class) that is connected to a simple TCP socket server (just for testing) I have this code snippet :

Dim aSocket as Socket
While aSocket.Connected = True
                     byteRead = aSocket.Receive(dataByte) 'number of bytes
                    'checking the number of bytes
                    If byteRead > 0 Then
                        data = System.Text.Encoding.ASCII.GetString(dataByte, 0, byteRead)
                     End if

Do Processing
                data Nothing
                byteRead = Nothing
end while

I have also a procedure that is checking the connection state and try to reconnect and do the working stuff...After try to reconnect on a new socket and reading data i receive a message error on this line : byteRead = aSocket.Receive(dataByte) 'number of bytes "An existing connection was forcibly closed by the remote host“

I have perform some searches on the internet but i did not find anything. Could be related of the way of reading data?

4

1 回答 1

0

我发现了问题...一些TcpSocket.Close()在某些功能中调用...

于 2012-04-23T13:14:06.983 回答