We help IT Professionals succeed at work.
Get Started

Problem porting app to Terminal Servics because of IP Port usage.

550 Views
Last Modified: 2012-08-20
We have a client server application that works very well in a standard windows installation.  We would now like to port the app so it can work in a MultiPoint 2011 Server.

We had one problem with config files being locked by one user, but have gotten around this using User Settings. But we have one problem left.  The different instances of the application open a TCP UDP port for listening to broadcast messages to indicate a status change on another instance.

The problem arises on terminal services / multipoint server when two users run the app, the second user gets an error as the IP / Port is already open with the first instance.

I have instructed Multipoint to assisgn a seperate IP address for each session, but this does not seem to help.

Below is the code I use for listening, I am hopng someone can suggest where I am going wrong.

Thanks

private static bool _isClosing;
private static bool _isNetUp;
private static UdpClient _udpClient;
private static IPEndPoint _remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);

private static void ReceiveMsgs()
        {
            while (!_isClosing)
            {
                if (!_isNetUp)
                {
                    _udpClient = new UdpClient(2000);

                    _isNetUp = true;
                }

                while (!_isClosing)
                {
                    var buffer = _udpClient.Receive(ref _remoteEndPoint);

                    SystemDateMessage msg;

                    using (var ms = new MemoryStream(buffer))
                    {
                        var bf = new BinaryFormatter();

                        try
                        {
                            msg = (SystemDateMessage)bf.Deserialize(ms);
                        }
                        catch (SerializationException e)
                        {
                            ExceptionHandling.Debug("Failed to deserialise system date message. Reason: " + e.Message);
                            throw;
                        }
                        finally
                        {
                            ms.Close();
                        }
                    }

                    ProcessMessage(msg);
                }
                Thread.Sleep(1000);
            }
        }

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE