I’m making a program which sends data to many TCP listeners. If one of the TCP Sending channel is no more used, do we need to close it using TCPClient.close. What happens if we leave it open?
Thanks!
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.
I wouldn’t use
Closeexplicitly – I’d just dispose it via ausingstatement:If neither side closes the connection, it’ll be sitting there doing nothing, pointlessly.
If the other end closes the connection, I suspect you’ll have a local connection in TIME_WAIT or something similar for a while; I don’t know the exact details but it’s not ideal.
The main point is that it may use up some system resources, and fundamentally it’s not ideal. Is it going to cause your program to crash and your system to go crazy? Probably not – at least unless you’re creating a huge number of these. It’s still a good idea to dispose of anything with non-memory resources though.