{
private bool islistening;
private bool useoverlappedIO;
+ private const int SOCKET_CLOSED = 10004;
static void AddSockets (List<Socket> sockets, IList list, string name)
{
int error = 0;
IntPtr sock = (IntPtr) (-1);
- blocking_thread = Thread.CurrentThread;
try {
+ RegisterForBlockingSyscall ();
sock = Accept_internal(socket, out error, blocking);
- } catch (ThreadAbortException) {
- if (disposed) {
- Thread.ResetAbort ();
- error = (int) SocketError.Interrupted;
- }
} finally {
- blocking_thread = null;
+ UnRegisterForBlockingSyscall ();
+ }
+
+ if (error != 0) {
+ if (closed)
+ error = SOCKET_CLOSED;
+ throw new SocketException(error);
}
- if (error != 0)
- throw new SocketException (error);
-
Socket accepted = new Socket(this.AddressFamily, this.SocketType,
this.ProtocolType, sock);
int error = 0;
IntPtr sock = (IntPtr)(-1);
- blocking_thread = Thread.CurrentThread;
try {
+ RegisterForBlockingSyscall ();
sock = Accept_internal (socket, out error, blocking);
- } catch (ThreadAbortException) {
- if (disposed) {
- Thread.ResetAbort ();
- error = (int)SocketError.Interrupted;
- }
} finally {
- blocking_thread = null;
+ UnRegisterForBlockingSyscall ();
}
- if (error != 0)
+ if (error != 0) {
+ if (closed)
+ error = SOCKET_CLOSED;
throw new SocketException (error);
+ }
acceptSocket.address_family = this.AddressFamily;
acceptSocket.socket_type = this.SocketType;
if (offset > buffer.Length)
throw new ArgumentOutOfRangeException ("offset", "offset must be <= buffer.Length");
- if (size < 0)
- throw new ArgumentOutOfRangeException ("size", "size must be >= 0")
+ if (size < 0)
+ throw new ArgumentOutOfRangeException ("size", "size must be >= 0");
if (size > buffer.Length - offset)
throw new ArgumentOutOfRangeException ("size", "size must be <= buffer.Length - offset");
res.Size = e.Count;
res.EndPoint = e.RemoteEndPoint;
res.SockFlags = e.SocketFlags;
- Worker worker = new Worker (e);
int count;
lock (readQ) {
- readQ.Enqueue (worker);
+ readQ.Enqueue (e.Worker);
count = readQ.Count;
}
if (count == 1)
res.Size = e.Count;
res.SockFlags = e.SocketFlags;
res.EndPoint = e.RemoteEndPoint;
- Worker worker = new Worker (e);
int count;
lock (writeQ) {
- writeQ.Enqueue (worker);
+ writeQ.Enqueue (e.Worker);
count = writeQ.Count;
}
if (count == 1)