private DoOperationAccept ( Socket socket, SafeCloseSocket handle, SafeCloseSocket acceptHandle, int &bytesTransferred ) : SocketError | ||
socket | Socket | |
handle | SafeCloseSocket | |
acceptHandle | SafeCloseSocket | |
bytesTransferred | int | |
리턴 | SocketError |
public bool AcceptAsync(SocketAsyncEventArgs e) { bool retval; if (s_loggingEnabled) { Logging.Enter(Logging.Sockets, this, "AcceptAsync", ""); } if (CleanedUp) { throw new ObjectDisposedException(GetType().FullName); } if (e == null) { throw new ArgumentNullException("e"); } if (e._bufferList != null) { throw new ArgumentException(SR.net_multibuffernotsupported, "BufferList"); } if (_rightEndPoint == null) { throw new InvalidOperationException(SR.net_sockets_mustbind); } if (!_isListening) { throw new InvalidOperationException(SR.net_sockets_mustlisten); } // Handle AcceptSocket property. SafeCloseSocket acceptHandle; e.AcceptSocket = GetOrCreateAcceptSocket(e.AcceptSocket, true, "AcceptSocket", out acceptHandle); // Prepare for the native call. e.StartOperationCommon(this); e.StartOperationAccept(); // Local variables for sync completion. int bytesTransferred; SocketError socketError = SocketError.Success; // Make the native call. try { socketError = e.DoOperationAccept(this, _handle, acceptHandle, out bytesTransferred); } catch (Exception ex) { // Clear in-use flag on event args object. e.Complete(); throw ex; } // Handle completion when completion port is not posted. if (socketError != SocketError.Success && socketError != SocketError.IOPending) { e.FinishOperationSyncFailure(socketError, bytesTransferred, SocketFlags.None); retval = false; } else { retval = true; } if (s_loggingEnabled) { Logging.Exit(Logging.Sockets, this, "AcceptAsync", retval); } return retval; }