Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to work with this library for telnet connections. I have called the function correctly and it executes the code below but fails giving the following error:

System.Net.Sockets.SocketException was unhandled
  HResult=-2147467259
  Message=No such host is known
  Source=System
  ErrorCode=11001
  NativeErrorCode=11001
  StackTrace:
       at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
       at MinimalisticTelnet.TelnetConnection..ctor(String Hostname, Int32 Port) in c:userskylecdocumentsvisual studio 2010ProjectsMail Server CaptureMail Server CaptureTelnetInterface.cs:line 36
       at Mail_Server_Capture.Form1.btn_MailGet_Click(Object sender, EventArgs e) in c:userskylecdocumentsvisual studio 2010ProjectsMail Server CaptureMail Server CaptureForm1.cs:line 55
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Mail_Server_Capture.Program.Main() in c:userskylecdocumentsvisual studio 2010ProjectsMail Server CaptureMail Server CaptureProgram.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

Code:

public TelnetConnection(string Hostname, int Port)
        {
            tcpSocket = new TcpClient(Hostname, Port);

        }

I have searched here looking for this problem and it seems pretty common. Some people are saying the host truly is unreachable (this is not the case), its a Microsoft .NET problem or its just an exception that can be ignored. I can't seem to get the program to pass it though if it is something that can be ignored. I also can't seem to find any solutions as to fixing it. I'm pretty lost on this one, any help would be appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
382 views
Welcome To Ask or Share your Answers For Others

1 Answer

Related but rare/fringe case: I was getting this same error in my C# .NET 4.7.2 web app (calling a http endpoint) because the machine I was on (a Parallels Win10 VM) had silently lost its network connection (no internet) due to some Parallels bug. Once I disabled and re-enabled the network adapter the error went away. /eyeroll


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...