473,671 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'System.Net.Soc kets.TcpListene r.TcpListener(i nt) is obsolete

Setting a server to listen on 8080 for incoming connections. Written in
VS2005 on a Multi-homed machine.
I get the warning:
Warning 1 'System.Net.Soc kets.TcpListene r.TcpListener(i nt)' is obsolete:
'This method has been deprecated. Please use TcpListener(IPA ddress
localaddr, int port) instead.
on the code:
TcpListener tcpListener = new TcpListener(808 0);

Do I really have to specify every IP address that I want to listen on?

The program compiled by changing the code to:

Int32 port = 8080;

IPAddress localAddr = IPAddress.Parse ("127.0.0.1" );

TcpListener tcpListener = new TcpListener(loc alAddr, port);

But does it mean that I am only listening on 127.0.0.1:8080? Why do I have
to specify an IP address I thought that specifying a port automatically
meant that you would be listening on that port for all IP addresses?

Just want to understand why
Mar 23 '08 #1
1 8626
Darwin wrote:
Setting a server to listen on 8080 for incoming connections. Written in
VS2005 on a Multi-homed machine.
I get the warning:
Warning 1 'System.Net.Soc kets.TcpListene r.TcpListener(i nt)' is obsolete:
'This method has been deprecated. Please use TcpListener(IPA ddress
localaddr, int port) instead.
on the code:
TcpListener tcpListener = new TcpListener(808 0);

Do I really have to specify every IP address that I want to listen on?
No. Use IpAddress.Any to listen on all local addresses.
The program compiled by changing the code to:

Int32 port = 8080;

IPAddress localAddr = IPAddress.Parse ("127.0.0.1" );
This is clumsy; IPAddress.Loopb ack is a constant field for this. And yes,
this only listens on 127.0.0.1, so external hosts can't reach it.

--
J.
Mar 23 '08 #2

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

Similar topics

8
1333
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland newsgroups I learned that there is a function in stdlib.h called system. int system(const char *command); First question, is the system command ANSI compliant. Because I include <cstdlib> and write std::system(command.c_str()); it looks like an...
4
4394
by: Rob White | last post by:
OK, so I have a TcpListener that is waiting for sockets, this piece of code: IPAddress localAddress = Dns.GetHostByName(Dns.GetHostName()).AddressList; IPEndPoint localEP = new IPEndPoint(localAddress, 9000); TcpListener tcpListen = new TcpListener(localEP); tcpListen.Start(); Socket skt = tcpListen.AcceptSocket(); .... do some socket stuff skt.Close();
0
1639
by: Pat Ireland | last post by:
To use the InvokeMember for calling a method in a dynamically loaded class requires that any arguments to the method must be past in an object . However, when I try to perform a pass by reference for an Int16 (short) object, I have not been able to successful make the conversion. Using boxing, gives me a type of object System.Reflection.Pointer, obviously not an System.Int16 *. By checking the parameters of the to be called method, it...
2
1762
by: Curious | last post by:
Hi, I have a similar class to the one shown below, with the main difference that it has more properties. Now I am using the enum to indicate what type of data current exists. I am using XmlSerialization to transfer the data over Sockets (TcpClient, TcpListener). Now when data is arriving at destination, MessageType is always being
29
2664
by: john | last post by:
I read in the first question in the FAQ that both short and int are guaranteed to be able to hold values up to 32,767. Then why would one use an int instead of a short if short takes less space?
6
4641
by: Dan Holmes | last post by:
I have a class that i need a constraint of int, string, float or bool. I have tried the following but can't make VS accept it. I read the docs and they showed that any value type can be used unless it is nullable. Why doesn't this work? public class Metadata<T> where T: System.int line from the docs
3
3319
by: Whooty | last post by:
Hello, im kind of new in using C++ and I have a question, I tried some tutorials and eventualy came to the part where the system namespace is used, but for some reason it won't work, #include <iostream> using namespace std; using namespace System; int main() { std::cout << "Welcome to C++/CLI Programming. ";
3
5398
by: nelsonbrodyk | last post by:
Hey all, Just curious, I want to make the "set" in a property obsolete, but not the get or the property. Is there a way to do this? Public string FirstName { get; set; } works fine, but this fails:
23
2128
by: student.matt | last post by:
ok i am trying to solve this little problem i have my program waits for the 1st system() call to finish before starting the next i will just throw an example of what i mean out in this example it waits for the 1st kedit to be closed before it opens the second #include <stdio.h> #include <stdlib.h> int main()
0
8472
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8390
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8667
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6222
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4221
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1801
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.