Re: Remoting on Terminal Server
- From: tosch <tosch@xxxxxxxxxxxxx>
- Date: Thu, 21 Feb 2008 06:47:08 -0800 (PST)
On 21 Feb., 15:05, Nicolas Bouchard <nicolas.bouch...@xxxxxxxxx>
wrote:
On Feb 21, 7:31 am, tosch <to...@xxxxxxxxxxxxx> wrote:
I have to apps that communicate using remoting. This works fine on a
single machine.
When I run the same on a terminal server I get an error when
registering a channel, when the second client starts the application.
Why do I get this error? How can I resolve this Issue
Tosch
The problem you have is due to the fact that you cannot open more than
1 port on the same computer.
I had the same situation lately. The solution I used is quite
simple. I get the session id from the terminal server and add it to
my port. That assure me I got a unique port for every session. To get
the remoting session id use the following method:
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
static extern bool ProcessIdToSessionId(uint dwProcessId, out
uint pSessionId);
public long GetRemotingPort()
{
uint sessionId = 0;
System.Diagnostics.Process currentProcess =
System.Diagnostics.Process.GetCurrentProcess();
bool result = ProcessIdToSessionId((uint)currentProcess.Id,
out sessionId);
return 65000 + sessionId;
}
In this example, I removed all error trapping validation. The base
port i was using is 65000 and if not on a terminal server, the
ProcessIdToSessionId returns 0.
Nicolas Bouchard
Nicolas,
thanks for your good solution. Can the port number ever be to big?
What's the max for the session id?
Thomas
.
- Follow-Ups:
- Re: Remoting on Terminal Server
- From: Nicolas Bouchard
- Re: Remoting on Terminal Server
- References:
- Remoting on Terminal Server
- From: tosch
- Re: Remoting on Terminal Server
- From: Nicolas Bouchard
- Remoting on Terminal Server
- Prev by Date: Re: Remoting on Terminal Server
- Next by Date: Re: Remoting on Terminal Server
- Previous by thread: Re: Remoting on Terminal Server
- Next by thread: Re: Remoting on Terminal Server
- Index(es):
Relevant Pages
|