Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- System.IO.IOException A connection attempt failed because the connected party did not
- properly respond after a period of time, or established connection failed because
- connected host has failed to respond.
- public byte[] Receive()
- {
- byte[] readBuffer = new byte[1024];
- byte[] realReceivedBytes = new byte[0];
- try
- {
- if (NetworkStream.CanRead)
- {
- int receivedBytesCount = 0;
- receivedBytesCount = NetworkStream.Read(readBuffer, 0, 1024);
- realReceivedBytes = new byte[receivedBytesCount];
- Array.Copy(readBuffer, 0, realReceivedBytes, 0, receivedBytesCount);
- }
- return realReceivedBytes;
- }
- catch (System.IO.IOException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- catch (System.IO.IOException)
- {
- if (!client.Connected)
- {
- Log("Client is not connected to host anymore.");
- break;
- }
- else
- {
- Log(String.Format("Error connecting to host. Retry attempt no. {0}",
- (numTries + 1)));
- Thread.Sleep(100);
- numTries++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement