When closing down my server I get the following exception
An unhandled exception of type 'System.Invalid OperationExcept ion' occurred
in system.dll
Additional information: AcceptCallback
I beleive that it is the asynchronous BeginAccept call which causes the
problem. How can I avoid this? Here is the code:
private void ListenForClient s()
{
listener = new Socket(AddressF amily.InterNetw ork, SocketType.Stre am,
ProtocolType.Tc p);
listener.Bind(n ew IPEndPoint(IPAd dress.Any, 9123));
listener.Listen (10);
listener.BeginA ccept(new AsyncCallback(t his.OnAccept), listener);
Invoke(new UpdateEventList Delegate(Update EventList), new object[] {
"Listening for clients..." } );
}
private void radioButtonStop ped_CheckedChan ged(object sender,
System.EventArg s e)
{
if (radioButtonSto pped.Checked == true)
{
Invoke(new UpdateEventList Delegate(Update EventList), new object[] {
"Closing server..." } );
listener.Close( );
listeningThread .Abort();
An unhandled exception of type 'System.Invalid OperationExcept ion' occurred
in system.dll
Additional information: AcceptCallback
I beleive that it is the asynchronous BeginAccept call which causes the
problem. How can I avoid this? Here is the code:
private void ListenForClient s()
{
listener = new Socket(AddressF amily.InterNetw ork, SocketType.Stre am,
ProtocolType.Tc p);
listener.Bind(n ew IPEndPoint(IPAd dress.Any, 9123));
listener.Listen (10);
listener.BeginA ccept(new AsyncCallback(t his.OnAccept), listener);
Invoke(new UpdateEventList Delegate(Update EventList), new object[] {
"Listening for clients..." } );
}
private void radioButtonStop ped_CheckedChan ged(object sender,
System.EventArg s e)
{
if (radioButtonSto pped.Checked == true)
{
Invoke(new UpdateEventList Delegate(Update EventList), new object[] {
"Closing server..." } );
listener.Close( );
listeningThread .Abort();
Comment