Kill Port

coolfire

Newcomer
Joined
Oct 6, 2003
Messages
14
Hi all,
i wrote my listener that way:
.....
private static TcpListener listener = null;
.....
listener = new TcpListener(ipText,Port);
listener.Start();
....
listener.Stop();


My question:
If i kill my Programm with an external Programm(terminate Process) my Port is still in use and when i would like to start my Programm(Listener) again this Socket-exception comes:
Only one usage of each socket address is normally permitted.
Therefore how can i close the Port before i start my Listener?
Thx
 
coolfire, if you put the above code in a try catch block, do you catch an exception when you kill the program...maybe it's possible to cleanup more gracefully....a thought.
 
Back
Top