开发者

Exception in the Socket#33711845::DoBind - Only one usage of each socket address (protocol/network address/port) is normally permitted

开发者 https://www.devze.com 2022-12-22 18:36 出处:网络
I\'m attempting to setup a simple remoting windows service and getting the following error when starting the service:

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开发者_如何学JAVA 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'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.
...

0

精彩评论

暂无评论...
验证码 换一张
取 消