首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tcplistener没有启动

tcplistener没有启动
EN

Stack Overflow用户
提问于 2011-10-17 15:11:06
回答 1查看 2K关注 0票数 2

我在Windows应用程序中使用TcpListener;该应用程序有一个启动TcpListener的“开始”按钮。但是,当我单击“开始”按钮时,将引发以下异常:

请求的地址在其上下文中无效

这是我用来启动侦听器的代码:

代码语言:javascript
复制
IPAddress FriendIp = IPAddress.Parse(IpAddress);
server = new TcpListener(FriendIp, PortNum);
server.Start();

这是异常的调用堆栈:

代码语言:javascript
复制
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端口,bool serverclient作业)第46行+ 0x10字节C# BlueBall.exe!BlueBall.BlueBall.Main_ListBox_DoubleClick(object发件人,System.EventArgs e)第221行+ 0x29字节C# System.Windows.Forms.dll!System.Windows.Forms.Control.OnDoubleClick(System.EventArgs e) + 0x7f字节

( System.Windows.Forms.dll!System.Windows.Forms.ListBox.WndProc(ref System.Windows.Forms.Message m) + 0x2c9字节System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0x13字节

System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x31字节

System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd,int msg,System.IntPtr wparam,System.IntPtr lparam) + 0x64字节

System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID,int原因,int pvLoopData) + 0x287字节

System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int原因,System.Windows.Forms.ApplicationContext上下文)+ 0x16c字节

System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int原因,System.Windows.Forms.ApplicationContext上下文)+ 0x61字节

( System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x31字节

BlueBall.exe!BlueBall.Program.Main()行18 + 0x1d字节C#原生于托管转换

mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile,System.Security.Policy.Evidence assemblySecurity,string[] args) + 0x6d字节

Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x2a字节

mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object状态)+ 0x63字节

mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext,System.Threading.ContextCallback回调,对象状态,bool ignoreSyncCtx) + 0xb0字节

mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext,System.Threading.ContextCallback回调,对象状态)+ 0x2c字节

mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44字节

原生于托管转换

EN

回答 1

Stack Overflow用户

发布于 2011-10-17 15:28:04

哈罗德和斯彭德是正确的,TcpListener只能绑定到被实例化的机器上的本地IP地址。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7795774

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档