473,769 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# VS.NET 2003 : System.Net.IpAd dress.IpAddress Obsolete

47 New Member
Hello,

I am trying to find a newer way of implementing the following but I am unsuccessful thus far:

Expand|Select|Wrap|Line Numbers
  1.         private void SetDataPort(IPEndPoint ep)
  2.         {            
  3.             byte[] hostBytes = BitConverter.GetBytes(ep.Address.Address);
  4.  
  5. .......
  6.  
At the moment I am getting the following error message:

Expand|Select|Wrap|Line Numbers
  1. 'System.Net.IPAddress.Address' is obsolete: 'IPAddress.Address is address family dependant, use Equals method for comparison.'
  2.  
Any ideas of the correct way of doing this?

Thanks.
Apr 11 '08 #1
2 4024
Mr Gray
47 New Member
This method seems to have fixed my issue:

Expand|Select|Wrap|Line Numbers
  1.             IPAddress ip = ep.Address;
  2.             string s = ip.ToString();
  3.             long Address = Convert.ToInt64(s);
  4.             byte[] hostBytes = BitConverter.GetBytes(Address);
  5.  
Thanks.
Apr 11 '08 #2
Plater
7,872 Recognized Expert Expert
Seems like it would be less work to just do this?
Expand|Select|Wrap|Line Numbers
  1. System.Net.IPAddress ip = ep.Address;
  2. byte[] hostBytes = ip.GetAddressBytes();
  3.  
or even
Expand|Select|Wrap|Line Numbers
  1. byte[] hostBytes = ep.Address.GetAddressBytes();
  2.  
Apr 11 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1850
by: Grandma Wilkerson | last post by:
Hi, This is your grandmother. I'm have a situation where I have access to an IPAddress and a mask and need to determine if another IP address is included in the IP block specified by former IP address and mask. The function prototype looks something like this: bool IsIPAddressInBlock(IPAddress neworkID,IPAddress mask,IPAddress test){
10
6782
by: Michael Riggio | last post by:
Does anyone know why this property is obsolete? Also, is there an alternative available?
10
2770
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows 2003 Server or ADO or ODBC issue, I am posting this on all of the three newsgroups. That's the setup: Windows 2003 Server with IIS and ASP.NET actiavted Access 2002 mdb file (and yes, proper rights are set on TMP paths and path,
2
1283
by: James R. Atherton | last post by:
I borrowed some code (Listed below) in VB.NET 2002, and it works great. I upgraded to 2003 and although this snippet still works, the (.AddressList(0).Address) portion of it has a squiggly line under it and states the following: 'Public Property Address() As Long' is obsolete: 'IPAddress.Address is address family dependant, use Equals method for comparison.' I would like to fix this, but have no idea how. It's not failing out my...
4
2678
by: Mika M | last post by:
Hi! Earlier using VB 2003 I used... Net.Dns.Resolve(Net.Dns.GetHostName()).AddressList(0).ToString() ....to retrieve IP-address of the local (first) NIC. Now I'm starting to use VB 2005, and don't know how to do this same (get IP-address) using new way of VB 2005?
10
3963
by: Frank | last post by:
Hi, I am hoping to find out the differences between the System.Net.Mail and System.Web.Mail. Can some nice folks post the differences; or some urls which show the differences? Great Thanks Frank
1
8640
by: Darwin | last post by:
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.Sockets.TcpListener.TcpListener(int)' is obsolete: 'This method has been deprecated. Please use TcpListener(IPAddress localaddr, int port) instead. on the code: TcpListener tcpListener = new TcpListener(8080); Do I really have to specify every IP address that I want to listen on?
3
8147
by: Brian | last post by:
Hi.. I don't get it.... this procedure is obsolete.. that is obsolete.... I am trying to rewrite a program i wrote in vb 6 years ago Dim hostIPAddress As IPAddress = IPAddress.Parse(Me.txtLookupHostIP.Text) Dim hostinfo As IPHostEntry = System.Net.Dns.GetHostEntry(hostIPAddress.ToString) ?system.Net.Dns.Resolve(hostIPAddress.ToString)
0
9579
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...
1
9987
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9857
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...
0
8867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6662
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
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3952
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
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
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.