Am using socket connection to send and receive values. The following code is used to receive response.
while ((sizeReceived = skt.Receive(bytesReceived, bytesReceived.Length, SocketFlags.None)) > 0)
nTotalBytes += sizeReceived;
sCleanresponse += Encoding.ASCII.GetString(bytesReceived, 0, sizeReceived);
//Giving time to read the remaining amount
if (skt.Available > 0)
In the above code, am facing a prob in skt.Available. If i dont give the thread.sleep, it is not repeating the while loop and it exits after onetime. And if i dont give skt.Available line, sometimes it throws socket Exception. I do not want to use thread.sleep. Does anyone knows why this is happening and how can i resolve this?
View Complete Post