473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

47
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 4000
Mr Gray
47
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 Expert 4TB
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
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...
10
by: Michael Riggio | last post by:
Does anyone know why this property is obsolete? Also, is there an alternative available?
10
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...
2
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...
4
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,...
10
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...
1
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:...
3
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 =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.