Connecting Tech Pros Worldwide Help | Site Map

determine IP address for TCPListener

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 21st, 2005, 03:52 PM
Keith Langer
Guest
 
Posts: n/a
Default determine IP address for TCPListener

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, 03:52 PM
Sunny
Guest
 
Posts: n/a
Default 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, 03:53 PM
Keith Langer
Guest
 
Posts: n/a
Default 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]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.