English 中文(简体)
履历
原标题:tcplistener does not start

我在视窗申请表中使用<代码>TcpListener;该编码有一个起步纽,即<代码>TcpListener。 然而,当我点击起纽顿时,有人提出了以下例外:

所要求的地址在此处不适用。

这是我开始听取意见的守则:

IPAddress FriendIp = IPAddress.Parse(IpAddress);
server = new TcpListener(FriendIp, PortNum);
server.Start();

This is the call stack for the exception:

System.dll!System.Net.Sockets.Socket.DoBind(System.Net.EndPoint endPointSnapshot, System.Net.SocketAddress socketAddress) + 0x9f bytes  
System.dll!System.Net.Sockets.Socket.Bind(System.Net.EndPoint localEP) + 0xd2 bytes 
System.dll!System.Net.Sockets.TcpListener.Start(int backlog) + 0x91 bytes   
System.dll!System.Net.Sockets.TcpListener.Start() + 0xa bytes   

BlueBall.exe!BlueBall.Chat_Window.Chat_Window(string ipadd, int port, bool serverclientjob) Line 46 + 0x10 bytes C# BlueBall.exe!BlueBall.BlueBall.Main_ListBox_DoubleClick(object sender, System.EventArgs e) Line 221 + 0x29 bytes C# System.Windows.Forms.dll!System.Windows.Forms.Control.OnDoubleClick(System.EventArgs e) + 0x7f bytes
System.Windows.Forms.dll!System.Windows.Forms.ListBox.WndProc(ref System.Windows.Forms.Message m) + 0x2c9 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0x13 bytes
System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x31 bytes
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) + 0x64 bytes [Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) + 0x287 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) + 0x16c bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x61 bytes
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x31 bytes
BlueBall.exe!BlueBall.Program.Main() Line 18 + 0x1d bytes C# [Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x6d bytes
Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2a bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x63 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xb0 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes
[Native to Managed Transition]

问题回答

Harold and Spender are correct, the TcpListener can only bind to a local IP Address on the machine where it is instantiated.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签