尝试打开 TcpChannel 时出现错误 10048
我对远程处理非常缺乏经验。 我正在尝试使用它,但在打开 TcpChannel 时不断收到 WinSock 错误 10048。
我使用 MSDN 中最简单的代码:
TcpChannel serverChannel = new TcpChannel(9090);
ChannelServices.RegisterChannel(serverChannel);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(RemoteObject), "RemoteObject.rem",
WellKnownObjectMode.Singleton);
第一次运行时,它可以正常工作并退出,但第二次运行时,我不断收到错误 10048,就像套接字 9090 已在使用中一样。 Netstat -a 根本不显示端口 9090,就像它已经关闭一样。
我究竟做错了什么?
I'm pretty inexperienced in Remoting. I'm trying to use it and keep receiving WinSock error 10048 when opening TcpChannel.
I use the simplest code from MSDN:
TcpChannel serverChannel = new TcpChannel(9090);
ChannelServices.RegisterChannel(serverChannel);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(RemoteObject), "RemoteObject.rem",
WellKnownObjectMode.Singleton);
When ran for the first time, it work and quit correctly, but for second and so on I keep receiving error 10048, like socket 9090 is already in use. Netstat -a do not show port 9090 at all, like it was closed already.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在在这里提问之前,我花了四天时间试图解决这个问题,并且已经有了答案:这只是 Windows XP 中的 WinSock 损坏了。
两个简单的 Windows 命令解决了该问题:
netsh int ip Reset Resetlog.txt
netsh Winsock Reset
Prior to asking here I've spent four days trying to solve this, and already here's an answer: it's just WinSock in Windows XP was corrupted.
Two simple Windows commands solved the problem:
netsh int ip reset resetlog.txt
netsh winsock reset
错误10048对应于WSAEADDRINUSE,这意味着该地址已被使用。 据我所知,这很可能意味着端口 9090 已被另一个应用程序占用。
Error 10048 corresponds to WSAEADDRINUSE, which means that the address is in use already. From what I can tell, it would most likely mean that port 9090 is already taken by another application.
是的当然。 问题是没有任何应用程序使用该端口(至少通过 netstat 可见)。 我尝试了许多其他端口,如 39000、9095 等,结果完全相同。
Yes, of course. Problem was that there wasn't any applications using that port (at least visible by netstat). I've tried many other ports like 39000, 9095 and so on, with exactly same results.
我怀疑 ISA 服务器防火墙客户端有时可能会导致这种行为。
I suspect ISA Server Firewall Client may sometimes cause that kind of behaviour.