2
Answers

Closing socket object not releasing port no in C#.

Photo of Sujeet Suman

Sujeet Suman

6y
985
1
Hi Friends,
I need your help. 
I am iterating over all local network interfaces(network adapter) to bind socket object. I am following below process:
 
(01.)  Creating socket object.
(02.)  Iterating over network interfaces & binding socket object.
(03.)  Using socket to send data on network.
(04.)  Closing socket object.
 
But here I am getting SocketException during binding at 2nd iteration. 
If any one having any idea or solution, then please share here. 
 

Answers (2)

0
Photo of Amit Gupta
NA 22.9k 248.1k 6y
Can you share your code, what you have done, it cannot be assumed what's wrong
Accepted
0
Photo of Sujeet Suman
378 4.1k 1.6m 6y
Thanks Amit for your reply. I got solution for this issue.
If we are sending some data on network & destination is not reachable due to some reason, then socket object is holding data for some time & throwing exception. So, I have used seprate thread for each thread & in case of exception aborting thread.