Home Forums Support Unable to create a TCP connection Reply To: Unable to create a TCP connection


Hi Marc,

thanks for the hint.

I solved it with a “failsafe” approach where each failed listener gets a log entry:

_listeners = new List<ConnectionListenerBase>();
      List<IPAddress> filteredLocalAddresses = HostInfo.IP.FilteredLocalAddresses();
      if (filteredLocalAddresses == null || filteredLocalAddresses.Count == 0) {
        throw new ApplicationException(String.Format("No filtered local addresses available to start listener for server of type {0}.", GetType().Name));
      foreach (var ipAddress in filteredLocalAddresses) {
        var endPoint = new IPEndPoint(ipAddress, ServerPort);
        try {
          Log(String.Format("Starting listener on end point {0}", endPoint.ToString()), TraceEventType.Verbose);
          var listener = new TCPConnectionListener(NetworkComms.DefaultSendReceiveOptions, ApplicationLayerProtocolStatus.Enabled);
          Connection.StartListening(listener, endPoint);
        } catch (Exception ex) {
          Log(String.Format("Listener on end point {0} could not start due to the following error: {1}", endPoint, ex.Message), TraceEventType.Error);