Blatwurst <(E-Mail Removed)> wrote:
> I've tried calling both Close() and/or Shutdown(). Socket doesn't
> have a Dispose(), or I would have tried that too. I also tried
> setting the Blocking property to false. Nothing I do will cause
> Accept() to either return or throw an exception.
Socket *does* have a Dispose method, you just need to cast it to
IDisposable first.
Do you have a small test app you're using to check this? If so, it
would be helpful if you could post it so I could try a few things.
Calling Close seems to work for me - the call to Accept throws a
SocketException. Here's my sample app:
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
class Test
{
static Socket skt;
static void Main()
{
skt = new Socket
(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.IP);
EndPoint endPoint = new IPEndPoint(IPAddress.Any, 12345);
skt.Bind(endPoint);
skt.Listen(10);
new Thread (new ThreadStart(StopMe)).Start();
skt.Accept();
}
static void StopMe()
{
Thread.Sleep(1000);
Console.WriteLine("Stopping");
skt.Close();
}
}
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too