public OSClient(IEFMagLinkRepository repository) { // First we set up our mutex and semaphore mutex = new Mutex(); connected = false; _repository = repository; item = new SocketAsyncEventArgs(); _timerClient.Elapsed += new System.Timers.ElapsedEventHandler(_timerClient_Elapsed); _timerClient.Interval = 10000; _timerClient.Start(); _timerClientConnecTimer.Elapsed += new System.Timers.ElapsedEventHandler(_timerClientConnecTimer_Elapsed); _timerClientConnecTimer.Interval = 15000; _timerClientConnecTimer.Start(); numconnections = 0; item.Completed += new EventHandler<SocketAsyncEventArgs>(OnIOCompleted); item.SetBuffer(new Byte[Convert.ToInt32(Settings._instance.BufferSize)], 0, Convert.ToInt32(Settings._instance.BufferSize)); socketpool = new OSAsyncEventStack(Convert.ToInt32(Settings._instance.NumConnect)); for (Int32 i = 0; i < Convert.ToInt32(Settings._instance.NumConnect); i++) { SocketAsyncEventArgs item1 = new SocketAsyncEventArgs(); item1.Completed += new EventHandler<SocketAsyncEventArgs>(OnIOCompleted); item1.SetBuffer(new Byte[Convert.ToInt32(Settings._instance.BufferSize)], 0, Convert.ToInt32(Settings._instance.BufferSize)); socketpool.Push(item1); } }
// Default constructor public OSServer(IEFMagLinkRepository repository) { _repository = repository; exceptionthrown = false; // First we set up our mutex and semaphore mutex = new Mutex(); numconnections = 0; // Then we create our stack of read sockets socketpool = new OSAsyncEventStack(Convert.ToInt32(Settings._instance.NumConnect)); // Now we create enough read sockets to service the maximum number of clients // that we will allow on the server // We also assign the event handler for IO Completed to each socket as we create it // and set up its buffer to the right size. // Then we push it onto our stack to wait for a client connection for (Int32 i = 0; i < Convert.ToInt32(Settings._instance.NumConnect); i++) { SocketAsyncEventArgs item = new SocketAsyncEventArgs(); item.Completed += new EventHandler<SocketAsyncEventArgs>(OnIOCompleted); item.SetBuffer(new Byte[Convert.ToInt32(Settings._instance.BufferSize)], 0, Convert.ToInt32(Settings._instance.BufferSize)); socketpool.Push(item); } }