Is there any faster way to tell if the client has data available? I’m not saying it is slow to use TcpClient.Available, but I am curious to know if it is the fastest way.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
TcpClient.Available is not slow in itself, it just depends how you use it.
If you only use it ponctually to check if there is available data, then it is the way to go.
If you use it in a loop in order to wait for data, the overall performance of your program will be quite bad. Here is one of this bad usage:
For this second scenario, you can achieve what you want using either: