private PosList <ArraySegment <byte> > GetSendingItems() { if (m_SendingItems == null) { m_SendingItems = new PosList <ArraySegment <byte> >(); } return(m_SendingItems); }
protected abstract void SendInternal(PosList <ArraySegment <byte> > items);
protected override void SendInternal(PosList <ArraySegment <byte> > items) { if (m_SocketEventArgsSend == null) { m_SocketEventArgsSend = new SocketAsyncEventArgs(); m_SocketEventArgsSend.Completed += new EventHandler <SocketAsyncEventArgs>(Sending_Completed); } bool raiseEvent; try { if (items.Count > 1) { if (m_SocketEventArgsSend.Buffer != null) { m_SocketEventArgsSend.SetBuffer(null, 0, 0); } m_SocketEventArgsSend.BufferList = items; } else { var currentItem = items[0]; try { if (m_SocketEventArgsSend.BufferList != null) { m_SocketEventArgsSend.BufferList = null; } } catch//a strange NullReference exception { } m_SocketEventArgsSend.SetBuffer(currentItem.Array, currentItem.Offset, currentItem.Count); } raiseEvent = Client.SendAsync(m_SocketEventArgsSend); } catch (SocketException exc) { int errorCode; errorCode = exc.ErrorCode; if (EnsureSocketClosed() && !IsIgnorableSocketError(errorCode)) { OnError(exc); } return; } catch (Exception e) { if (EnsureSocketClosed() && IsIgnorableException(e)) { OnError(e); } return; } if (!raiseEvent) { Sending_Completed(Client, m_SocketEventArgsSend); } }