示例#1
0
        public SocketListener(ISocketListenerSettings theSocketListenerSettings, ILog log)
        {
            this._socketListenerSettings = theSocketListenerSettings;
            this._log = log;
            _log.WriteLine("SocketListener constructor");
            //Allocate memory for buffers. We are using a separate buffer space for
            //receive and send, instead of sharing the buffer space, like the Microsoft
            //example does.
            this._theBufferManager = new BufferManager(this._socketListenerSettings.BufferSize * this._socketListenerSettings.NumberOfSaeaForRecSend * this._socketListenerSettings.OpsToPreAllocate,
                                                       this._socketListenerSettings.BufferSize * this._socketListenerSettings.OpsToPreAllocate);

            this._poolOfRecSendEventArgs = new AsyncSocketEventArgsPool(this._socketListenerSettings.NumberOfSaeaForRecSend, log);

            // Create a semaphore that can satisfy up to maxConnectionCount concurrent requests.
            _acceptedClientsSemaphore = new Semaphore(this._socketListenerSettings.MaxConnections, this._socketListenerSettings.MaxConnections);

            _sendingQueue = new BlockingCollection <MessageData>();

            _sendMessageWorker = new Thread(new ThreadStart(SendQueueMessage));

            Init();

            _waitSendEvent = new AutoResetEvent(false);
        }
 public SocketConnectionListener(IPEndPoint localEndpoint, ISocketListenerSettings settings, bool useOnlyOverlappedIO)
     : this(settings, useOnlyOverlappedIO)
 {
     this.localEndpoint = localEndpoint;
 }
 SocketConnectionListener(ISocketListenerSettings settings, bool useOnlyOverlappedIO)
 {
     Fx.Assert(settings != null, "Input settings should not be null");
     this.settings = settings;
     this.useOnlyOverlappedIO = useOnlyOverlappedIO;
     this.connectionBufferPool = new ConnectionBufferPool(settings.BufferSize);
 }
 public SocketConnectionListener(Socket listenSocket, ISocketListenerSettings settings, bool useOnlyOverlappedIO)
     : this(settings, useOnlyOverlappedIO)
 {
     this.listenSocket = listenSocket;
 }
 private SocketConnectionListener(ISocketListenerSettings settings, bool useOnlyOverlappedIO)
 {
     this.settings = settings;
     this.useOnlyOverlappedIO = useOnlyOverlappedIO;
     this.connectionBufferPool = new ConnectionBufferPool(settings.BufferSize);
 }
 public SocketConnectionListener(Socket listenSocket, ISocketListenerSettings settings, bool useOnlyOverlappedIO) : this(settings, useOnlyOverlappedIO)
 {
     this.listenSocket = listenSocket;
 }
 public SocketConnectionListener(IPEndPoint localEndpoint, ISocketListenerSettings settings, bool useOnlyOverlappedIO) : this(settings, useOnlyOverlappedIO)
 {
     this.localEndpoint = localEndpoint;
 }
 private SocketConnectionListener(ISocketListenerSettings settings, bool useOnlyOverlappedIO)
 {
     this.settings             = settings;
     this.useOnlyOverlappedIO  = useOnlyOverlappedIO;
     this.connectionBufferPool = new ConnectionBufferPool(settings.BufferSize);
 }