Connecting Tech Pros Worldwide Forums | Help | Site Map

determine IP address for TCPListener

Keith Langer
Guest
 
Posts: n/a
#1: Nov 22 '05
I have a TCPListener which needs to listen on my LAN IP as well as the
loopback address. In VS.Net 2002 the TCPListener constructor could
accept the port as an argument and it automatically bound to all
network adapters (this is also how it worked with VB6). Now that
constructor is obsolete, and the new one requires an IPEndPoint or
IPAddress.

How could I listen on the same port on all network adapters using
VS.Net 2003? I'd rather not use DNS.

thanks,
Keith

Sunny
Guest
 
Posts: n/a
#2: Nov 22 '05

re: determine IP address for TCPListener


From the docs (msdn) about TcpListener(IPEndpoint) constructor:

Remarks
This constructor allows you to specify the local IP address and port
number on which to listen for incoming connection attempts. Before using
this construcor, you must create an IPEndPoint using the desired local
IP address and port number. Pass this IPEndPoint to the constructor as
the localEP parameter.

If you do not care which local address is assigned, you can create an
IPEndPoint using IPAddress.Any as the address 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.

Does it help?

Sunny

In article <15c7b652.0407200742.769f518e@posting.google.com >,
tanalbit@aol.com says...[color=blue]
> I have a TCPListener which needs to listen on my LAN IP as well as the
> loopback address. In VS.Net 2002 the TCPListener constructor could
> accept the port as an argument and it automatically bound to all
> network adapters (this is also how it worked with VB6). Now that
> constructor is obsolete, and the new one requires an IPEndPoint or
> IPAddress.
>
> How could I listen on the same port on all network adapters using
> VS.Net 2003? I'd rather not use DNS.
>
> thanks,
> Keith
>[/color]
Keith Langer
Guest
 
Posts: n/a
#3: Nov 22 '05

re: determine IP address for TCPListener


Yes! That does exactly what I want.

thanks,
Keith


Sunny <sunny@newsgroups.nospam> wrote in message news:<e1I5ngnbEHA.2340@TK2MSFTNGP10.phx.gbl>...[color=blue]
> From the docs (msdn) about TcpListener(IPEndpoint) constructor:
>
> Remarks
> This constructor allows you to specify the local IP address and port
> number on which to listen for incoming connection attempts. Before using
> this construcor, you must create an IPEndPoint using the desired local
> IP address and port number. Pass this IPEndPoint to the constructor as
> the localEP parameter.
>
> If you do not care which local address is assigned, you can create an
> IPEndPoint using IPAddress.Any as the address 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.
>
> Does it help?
>
> Sunny
>
> In article <15c7b652.0407200742.769f518e@posting.google.com >,
> tanalbit@aol.com says...[color=green]
> > I have a TCPListener which needs to listen on my LAN IP as well as the
> > loopback address. In VS.Net 2002 the TCPListener constructor could
> > accept the port as an argument and it automatically bound to all
> > network adapters (this is also how it worked with VB6). Now that
> > constructor is obsolete, and the new one requires an IPEndPoint or
> > IPAddress.
> >
> > How could I listen on the same port on all network adapters using
> > VS.Net 2003? I'd rather not use DNS.
> >
> > thanks,
> > Keith
> >[/color][/color]
Closed Thread


Similar .NET Framework bytes