Dart Home | PowerTCP Emulation for .NET | Custom Development | Reply | PowerTCP Emulation for .NET Topics | Forums |
Author | Forum: PowerTCP Emulation for .NET Topic: Connect to non-standard port, how to set connect timeout? |
sbowyer From: Exeter, RI USA Posts: 4 Member Since: 11/07/11 |
posted April 10, 2012 10:09 AM Since I couldn't find it in documentation, here is how to connect to a port other than 23, for other people with this need: System.Net.IPAddress hostAddress = System.Net.IPAddress.Parse(aIpAddr); Dart.Emulation.IPEndPoint dartPoint = new Dart.Emulation.IPEndPoint(hostAddress, aPort); mTelnet.Connect(session); Now a question - How do I set a timeout for a telnet Connect() call? If the user puts in an invalid address, I don't want it to hang a long time/forever. |
Nick B (Admin) From: Utica, NY USA Posts: 619 Member Since: 05/25/10 Extra Support Options Custom Application Development |
posted April 10, 2012 11:24 AM Hello, No connect timeout is available because the .NET Framework Sockets does not provide a connect timeout. If you're connecting to a hostname that your DNS does not have a record for, the connect method will quickly return with a 'No such host is known' exception. If you're attempting to connect to a specific IP, then it will throw a 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond' exception after 20 seconds. If a connect timeout is required, you may setup a Timer where it calls Telnet.Close or Abort, and then instantiates a new instance of the Telnet class (it was not designed with this use in mind, I have entered an improvement request as TTWeb #5635 so that you will not need to re-instantiate the control in the Tick event) |
Reply | PowerTCP Emulation for .NET Topics | Forums |
This site is powered by
![]() |