We help IT Professionals succeed at work.

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

Medium Priority
544 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

CERTIFIED EXPERT
Most Valuable Expert 2017
Distinguished Expert 2019

Commented:
What you might need to do is have a master app run on the TS that listens on the port and the client apps "subscribe" to this master app communicating through another mechanism.
Commented:
After performing a bit more research I found an article on the web where someone else was using a UDPClient on a terminal server.  There are some additional setting s I can use to allow multiple apps use the same IP/port combination. I believe is the answer I was looking for.

Author

Commented:
After performing a bit more research I found an article on the web where someone else was using a UDPClient on a terminal server.  There are some additional setting s I can use to allow multiple apps use the same IP/port combination. I believe is the answer I was looking for.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.