simple.mailserver icon indicating copy to clipboard operation
simple.mailserver copied to clipboard

Way to stop the server or bind

Open philbertphotos opened this issue 9 years ago • 1 comments

I have been looking for a way to stop the listening port without coming out of the console app Is there something built in that I am missing or would I have to make a function to do this.

philbertphotos avatar Mar 19 '15 00:03 philbertphotos

Indeed this is hard to achieve. I should add some functionality to do that.

For now this could be a workaround:

// ...
smtpServer.BindAndListenTo(IPAddress.Loopback, 25);
// ...
// undo the binding from above
PortListener portListener;
if (smtpServer.Bindings.TryTake(out portListener))
{
    portListener.StopListen();
}
// ...

hanswolff avatar Mar 22 '15 20:03 hanswolff