Socket#33711845::DoBind 中的异常 - 通常只允许每个套接字地址(协议/网络地址/端口)使用一次

发布于 2024-08-24 18:22:14 字数 1439 浏览 3 评论 0原文

我正在尝试设置一个简单的远程 Windows 服务,并在启动该服务时出现以下错误:

System.Net.Sockets Error: 0 : [4180] Exception in the Socket#33711845::DoBind - Only one usage of each socket address (protocol/network address/port) is normally permitted
System.Net.Sockets Verbose: 0 : [4180] ExclusiveTcpListener#4032828::Start()
System.Net.Sockets Verbose: 0 : [4180] Socket#33711845::Bind(0:9998#9998)
System.Net.Sockets Error: 0 : [4180] Exception in the Socket#33711845::DoBind - Only one usage of each socket address (protocol/network address/port) is normally permitted

在 Windows 服务应用程序中,我在“OnStart”方法中有以下代码 - 注册通道时发生错误 - ChannelServices.RegisterChannel( tcpPipe,真);据我所知,没有其他进程使用端口 9998 ...

   protected override void OnStart(string[] args)
    {

        int portNumber = int.Parse(ConfigurationManager.AppSettings["endPointTCPPort"]);

        TcpChannel tcpPipe = new TcpChannel(portNumber);

        ChannelServices.RegisterChannel(tcpPipe, true);

        Type serviceType = Type.GetType("TractionGatewayService.TractionGateway");

        try
        {
           RemotingConfiguration.RegisterWellKnownServiceType(serviceType, "updateCustomerDetails", WellKnownObjectMode.SingleCall);
        }
        catch (RemotingException e)
        {
            EventLog.WriteEntry("unable to establish listening port because " + e.message; 
            ChannelServices.UnregisterChannel(tcpPipe);
        }

I'm attempting to setup a simple remoting windows service and getting the following error when starting the service:

System.Net.Sockets Error: 0 : [4180] Exception in the Socket#33711845::DoBind - Only one usage of each socket address (protocol/network address/port) is normally permitted
System.Net.Sockets Verbose: 0 : [4180] ExclusiveTcpListener#4032828::Start()
System.Net.Sockets Verbose: 0 : [4180] Socket#33711845::Bind(0:9998#9998)
System.Net.Sockets Error: 0 : [4180] Exception in the Socket#33711845::DoBind - Only one usage of each socket address (protocol/network address/port) is normally permitted

In the windows service application I have the following code in the "OnStart" method - the error occurs when registering the Channel - ChannelServices.RegisterChannel(tcpPipe, true); As far as I can tell there are no other processes using port 9998 ...

   protected override void OnStart(string[] args)
    {

        int portNumber = int.Parse(ConfigurationManager.AppSettings["endPointTCPPort"]);

        TcpChannel tcpPipe = new TcpChannel(portNumber);

        ChannelServices.RegisterChannel(tcpPipe, true);

        Type serviceType = Type.GetType("TractionGatewayService.TractionGateway");

        try
        {
           RemotingConfiguration.RegisterWellKnownServiceType(serviceType, "updateCustomerDetails", WellKnownObjectMode.SingleCall);
        }
        catch (RemotingException e)
        {
            EventLog.WriteEntry("unable to establish listening port because " + e.message; 
            ChannelServices.UnregisterChannel(tcpPipe);
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉生梦死 2024-08-31 18:22:14

我已经找到问题了。我对 TcpChannel 进行了两次单独的调用来注册端口 - 因此出现了错误。
感谢所有看过此内容的人。
...

I've found the problem. I had two seperate calls to TcpChannel to register the port - hence the error.
thanks to everyone who has taken a look at this.
...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文