|
-
Feb 26th, 2008, 10:22 AM
#1
Thread Starter
Junior Member
TcpListener and IPAddress.Any
Hey guys,
I am currently living in a student house with 5 computers connected to a wireless router.
I was wondering, then, what IP address the IPAddress.Any method would return in VB.Net, as I am trying to set up a TcpListener using it.
Here is what I am trying to do: I want the TcpListener to start listening on the host computer port 3001 as soon as my VS programme starts. As far as I am aware, a TcpListener can only run on an internal IP, but I am not 100% sure how to get the internal IP of the host computer as I don't want to hard-code it so that the application will work on any computer that it is run on.
Is IPAddress.Any the right thing to use? If not, what is a better way of doing this?
Thanks,
K
-
Feb 26th, 2008, 10:33 AM
#2
Re: TcpListener and IPAddress.Any
The TcpListener can only listen on local IPs. Take a look at the documentation for that particual constructor overload, and you'll see that this is said about using IPAddress.Any:
If you do not care which local address is assigned, specify IPAddress.Any for the localaddr parameter, and the underlying service provider will assign the most appropriate network address. This might help simplify your application if you have multiple network interfaces.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|