/// <summary>
        /// Creates a new <see cref="TcpIPByteStreamHandler"/>.
        /// </summary>
        protected TcpIPByteStreamHandler(ReconnectWaitTimeGetter reconnectWaitTimeGetter, TimeSpan receiveTimeout)
        {
            reconnectWaitTimeGetter.MustNotBeNull(nameof(reconnectWaitTimeGetter));

            this.ReconnectWaitTimeGetter = reconnectWaitTimeGetter;
            this.ReceiveTimeout          = receiveTimeout;
        }
 public UdpByteStreamHandlerSettings(
     ushort listeningPort,
     string remoteHost, ushort remotePort,
     ReconnectWaitTimeGetter?reconnectWaitTimeGetter = null)
 {
     this.ListeningPort           = listeningPort;
     this.RemoteIPAddress         = IPAddress.None;
     this.RemotePort              = remotePort;
     this.RemoteHost              = remoteHost;
     this.ReconnectWaitTimeGetter = reconnectWaitTimeGetter ?? new FixedReconnectWaitTimeGetter(TimeSpan.FromSeconds(1.0));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new <see cref="TcpActiveByteStreamHandler"/> instance.
        /// </summary>
        /// <param name="remoteIPAddress">The ip address of the remote host.</param>
        /// <param name="remotePort">The remote port.</param>
        /// <param name="reconnectWaitTimeGetter">The <see cref="ReconnectWaitTimeGetter"/> which generates wait times after broke connection and before reconnect.</param>
        /// <param name="receiveTimeout">Connection will be closed when we don't receive anything in this period of time.</param>
        internal TcpActiveByteStreamHandler(
            IPAddress remoteIPAddress, ushort remotePort,
            ReconnectWaitTimeGetter reconnectWaitTimeGetter,
            TimeSpan receiveTimeout)
            : base(reconnectWaitTimeGetter, receiveTimeout)
        {
            remoteIPAddress.MustNotBeNull(nameof(remoteIPAddress));
            reconnectWaitTimeGetter.MustNotBeNull(nameof(reconnectWaitTimeGetter));
            receiveTimeout.MustBeGreaterThanOrEqualTo(TimeSpan.Zero, nameof(receiveTimeout));

            _startStopLock       = new object();
            this.RemoteHost      = remoteIPAddress.ToString();
            this.RemoteIPAddress = remoteIPAddress;
            this.RemotePort      = remotePort;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a new <see cref="TcpPassiveByteStreamHandler"/> instance.
        /// </summary>
        /// <param name="listeningIPAddress">The <see cref="IPAddress"/> this instance should listen on.</param>
        /// <param name="listeningPort">The port his instance should listen on. Pass 0 here if the OS should decide which port to use.</param>
        /// <param name="reconnectWaitTimeGetter">The <see cref="ReconnectWaitTimeGetter"/> which generates wait times after broke connection and before reconnect.</param>
        /// <param name="receiveTimeout">Connection will be closed when we don't receive anything in this period of time.</param>
        internal TcpPassiveByteStreamHandler(
            IPAddress listeningIPAddress,
            ushort listeningPort,
            ReconnectWaitTimeGetter reconnectWaitTimeGetter,
            TimeSpan receiveTimeout)
            : base(reconnectWaitTimeGetter, receiveTimeout)
        {
            listeningIPAddress.MustNotBeNull(nameof(listeningIPAddress));
            reconnectWaitTimeGetter.MustNotBeNull(nameof(reconnectWaitTimeGetter));
            receiveTimeout.MustBeGreaterThanOrEqualTo(TimeSpan.Zero, nameof(receiveTimeout));

            _startStopLock = new object();

            this.ListeningIPAddress  = listeningIPAddress;
            this.ListeningPort       = listeningPort;
            this.ActualListeningPort = listeningPort;
        }
        internal UdpByteStreamHandler(
            ushort listeningPort,
            string remoteHost, ushort remotePort,
            ReconnectWaitTimeGetter reconnectWaitTimeGetter)
            : base(reconnectWaitTimeGetter, TimeSpan.Zero)
        {
            remoteHost.MustNotBeNullOrEmpty(nameof(remoteHost));
            reconnectWaitTimeGetter.MustNotBeNull(nameof(reconnectWaitTimeGetter));

            this.ListeningPort   = listeningPort;
            this.RemoteHost      = remoteHost;
            this.RemoteIPAddress = IPAddress.None;
            this.RemotePort      = remotePort;

            _startStopLock = new object();
            _udpClient     = null;
            _isRunning     = false;
        }