/// <summary> /// Create TCP KSI service protocol /// </summary> /// <param name="ipAddress">Service IP address</param> /// <param name="port">Service port</param> /// <param name="requestTimeout">request timeout in milliseconds</param> /// <param name="bufferSize">size of buffer to be used when receiving data</param> public TcpKsiServiceProtocolBase(IPAddress ipAddress, ushort port, uint?requestTimeout = null, uint?bufferSize = null) { if (ipAddress == null) { throw new ArgumentNullException(nameof(ipAddress)); } _ipAddress = ipAddress; _port = port; if (requestTimeout.HasValue) { _requestTimeOut = (int)requestTimeout.Value; } if (bufferSize.HasValue) { if (bufferSize == 0) { throw new KsiServiceProtocolException("Buffer size should be a positive integer, but was (" + bufferSize + ")."); } _bufferSize = bufferSize.Value; } _receivedDataBuffer = new byte[_bufferSize]; _asyncResults = new TcpAsyncResultCollection(); _responseProcessor = new TcpResponseProcessor(_asyncResults); _waitSocketConnectHandle = new ManualResetEvent(false); }
/// <summary> /// Create TCP request response processor instance /// </summary> /// <param name="asyncResults">Collection of async results associated with TCP requests. Corresponding async results are searched and marked as done when parsing data received via TCP.</param> public TcpResponseProcessor(TcpAsyncResultCollection asyncResults) { _asyncResults = asyncResults; Clear(); }