473,486 Members | 2,407 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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
Jul 21 '05 #1
2 6442
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 <15**************************@posting.google.com >,
ta******@aol.com 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

Jul 21 '05 #2
Yes! That does exactly what I want.

thanks,
Keith
Sunny <su***@newsgroups.nospam> wrote in message news:<e1**************@TK2MSFTNGP10.phx.gbl>...
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 <15**************************@posting.google.com >,
ta******@aol.com 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

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2190
by: Stephen Remde | last post by:
what the kosher way of vreating a tcp client/server app in .net? can anyone recommend a good in depth tutorial? currently im using a TcpListener but i cant get a remotre address from the...
1
3768
by: Daniel | last post by:
after opening socket, sending data then closing socket 3000 times i get "Only one usage of each socket address" what am i doing wrong? is there some thing else i need to do to free up the socket...
2
2943
by: R2D2 | last post by:
Is there any way to resolve the ip address of the host machine or a machine at the other end of a network connection? I have created a client-server Tcp project that only uses the TcpClient and...
1
28839
by: Matt_is_a_novice | last post by:
I am writing a server to open a TCPListener, the client connects, and the server returns a Socket. I want to know what IP address is connected to my server. How do I retrieve the IP address of my...
1
2697
by: MuZZy | last post by:
HI, How do i get a remote TcpClient address here? // ======================================= TcpListener l = new TcpListener(IPAddress.Parse("127.0.0.1"), 8080); TcpListener.Start(); While...
2
270
by: Keith Langer | last post by:
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...
13
28704
by: Sandeep Singh | last post by:
I am making socket client application in C# how can i get ip address of client who has connected to server
6
14674
by: felix.citycs | last post by:
Why I cannot do with this code and exception is thrown with "the requested address is not valid in its context" try { IPAddress inputDNS_IP = Dns.Resolve(inputDNS_IP).AddressList; // start...
9
38046
by: pbd22 | last post by:
Hi. I am getting the below error: Event Type: Error Event Source: PeskyService Event Category: None Event ID: 0 Date: 1/30/2008 Time: 5:49:10 PM User: N/A
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.