PC Review


Reply
Thread Tools Rate Thread

determine IP address for TCPListener

 
 
Keith Langer
Guest
Posts: n/a
 
      20th Jul 2004
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
 
Reply With Quote
 
 
 
 
Sunny
Guest
Posts: n/a
 
      20th Jul 2004
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 <(E-Mail Removed)>,
(E-Mail Removed) says...
> 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
>

 
Reply With Quote
 
Keith Langer
Guest
Posts: n/a
 
      21st Jul 2004
Yes! That does exactly what I want.

thanks,
Keith


Sunny <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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 <(E-Mail Removed)>,
> (E-Mail Removed) says...
> > 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
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'System.Net.Sockets.TcpListener.TcpListener(int) is obsolete Darwin Microsoft C# .NET 3 23rd Mar 2008 06:19 PM
How do I determine my WAN address? =?Utf-8?B?TXJOb2JvZHk=?= Microsoft C# .NET 8 18th May 2006 02:21 PM
Determine my IP Address Cliff Cavin Microsoft VB .NET 3 29th Jan 2006 11:47 AM
determine MAC address John Grandy Windows XP Hardware 2 2nd Jun 2005 07:31 PM
Determine IP Address Jeff S Microsoft ASP .NET 1 6th Nov 2003 03:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:53 PM.