Connecting Tech Pros Worldwide Help | Site Map

determine IP address for TCPListener

  #1  
Old July 21st, 2005, 04:52 PM
Keith Langer
Guest
 
Posts: n/a
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
  #2  
Old July 21st, 2005, 04:52 PM
Sunny
Guest
 
Posts: n/a

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]
  #3  
Old July 21st, 2005, 04:53 PM
Keith Langer
Guest
 
Posts: n/a

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 Threads
Thread Thread Starter Forum Replies Last Post
Getting IP address of connected socket Zytan answers 6 March 21st, 2007 03:05 PM
determine IP address for TCPListener Keith Langer answers 2 November 22nd, 2005 12:54 PM