Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2007

Tip: Looking for answers? Try searching our database.

How to get the port number when its 0?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leon_Amirreza - 21 Jul 2007 02:58 GMT
I have created a TcpServerChannel with port number 0 and registered it
now I want the server to write its port number used on screen (host is a
console App)!
How can I do that?
Peter Duniho - 21 Jul 2007 03:39 GMT
> I have created a TcpServerChannel with port number 0 and registered it
> now I want the server to write its port number used on screen (host is a
> console App)!
> How can I do that?

Hah!  That's a lot harder question than it first appears.  :)

Anyway, I was curious, because I had never heard of the TcpServerChannel  
object in the first place.  I assumed that it'd have some sort of EndPoint  
property that would return the assigned address.  But alas, that wasn't  
the case.

This is a wild guess -- I don't have any code that uses a TcpServerChannel  
so I can't really test this theory -- but reading the docs it looks to me  
like this might work (C#):

    int PortFromChannel(TcpServerChannel channel)
    {
        ChannelDataStore store = (ChannelDataStore)channel.ChannelData;

        return store["port"];
    }

Pete

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.