tcp channel

Hi all,
I have this problem:
I have created tcp channel
TcpChannel myChannel = new TcpChannel();
and a want to know port . Can someone help me?


Comments

  • : Hi all,
    : I have this problem:
    : I have created tcp channel
    : TcpChannel myChannel = new TcpChannel();
    : and a want to know port . Can someone help me?
    :
    :
    :
    Hi,

    Try this

    tcpChannel = new TcpChannel(0);
    ChannelServices.RegisterChannel(tcpChannel);
    RemotingConfiguration.RegisterWellKnownServiceType(myServerType,"MyServer",WellKnownObjectMode.SingleCall);

    // pick apart the URL to retrieve the chosen port number.
    string[] urls = tcpChannel.GetUrlsForUri("MyServer");
    string objectUri;
    string uri = tcpChannel.Parse(urls[0],out objectUri);
    string strPort = uri.Substring(uri.LastIndexOf(":")+1);
    port = Convert.ToInt32(strPort);

    // Patrik
  • : : Hi all,
    : : I have this problem:
    : : I have created tcp channel
    : : TcpChannel myChannel = new TcpChannel();
    : : and a want to know port . Can someone help me?
    : :
    : :
    : :
    : Hi,
    :
    : Try this
    :
    : tcpChannel = new TcpChannel(0);
    : ChannelServices.RegisterChannel(tcpChannel);
    : RemotingConfiguration.RegisterWellKnownServiceType(myServerType,"MyServer",WellKnownObjectMode.SingleCall);
    :
    : // pick apart the URL to retrieve the chosen port number.
    : string[] urls = tcpChannel.GetUrlsForUri("MyServer");
    : string objectUri;
    : string uri = tcpChannel.Parse(urls[0],out objectUri);
    : string strPort = uri.Substring(uri.LastIndexOf(":")+1);
    : port = Convert.ToInt32(strPort);
    :
    : // Patrik

    thanx a lot,
    i 'm using this( the sam idea i have used regex), but it is too slow. I'm looking for somethig faster.




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories