473,769 Members | 4,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IPAddress creation

MG
Hello,

I try to create IPAddress object from array of bytes and it always throws
exception,
even when array of bytes is taken from proper IPAddress object:

IPAddress lAddress=IPAddr ess.Parse("1.2. 3.4");
byte[] lBytes=lAddress .GetAddressByte s();
IPAddress lNewAddress=new IPAddress(lByte s);

Has anyone encountered the problem?
Am I doing something wrong ??
(Im usingFramework 1.1)

Nov 15 '05 #1
2 1796
MG,

What is the exception that is thrown? Also, what are the contents of
the byte array that you are passing in? You should have a 16-element byte
array. The reason for this is to account for the fact that IP addresses are
being widened at some point in time.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"MG" <mg*****@elka.p w.edu.pl> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Hello,

I try to create IPAddress object from array of bytes and it always throws
exception,
even when array of bytes is taken from proper IPAddress object:

IPAddress lAddress=IPAddr ess.Parse("1.2. 3.4");
byte[] lBytes=lAddress .GetAddressByte s();
IPAddress lNewAddress=new IPAddress(lByte s);

Has anyone encountered the problem?
Am I doing something wrong ??
(Im usingFramework 1.1)

Nov 15 '05 #2
MG
Nicholas,

Thanks for help - passing array with 16 elements works.
Is there any info about this topic - I looked at online MSDN at
http://msdn.microsoft.com/library/de...ctortopic1.asp
but found no info on format of the passed array.

Thought that GetAddressBytes () method returns data that is sufficient to
create another object.
I will work it out with my own conversion.

Thanks.

MG
Nov 15 '05 #3

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

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?
6
7213
by: ed | last post by:
What is the difference between IPAddress::Any and IPAddress::Broadcast when being using by a TCPListener class?
5
11436
by: Stuart Norris | last post by:
Dear Readers, I am attempting to define an array of IPAddress-es in C#. I wish to have a array of address so I can try in order to connect to them in a loop to handle unavailable hosts. Todate since I do not know how to define an array of IPAddress-es. I have been defining variable like:
2
15089
by: David Dvali | last post by:
How can I use System.Net.IPAddress class? I want assign some IP for example: 85.125.20.60
2
6340
by: O.B. | last post by:
I have a an attribute within a Serializable class that is of type System.Net.IPAddress. When I try to serialize the class, I get the following error: System.InvalidOperationException: Cannot serialize member 'SerializationTest.ConfigurationProperties.ConnectionAddress' of type 'System.Net.IPAddress', see inner exception for more details. System.InvalidOperationException: System.Net.IPAddress cannot be serialized because it does not...
2
3123
by: Ryan Liu | last post by:
Hi, Can someone tell me how to calculate an IPaddress's long value? I have an application which lisiten on a port using UDP protocol. There could be multiple client sendind UDP data to it and I am only interested data from one client, I know that client's IP address in form of 127.0.0.1 etc. I think I need convert that IP into IPaddress then can compare with
1
4080
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
How might I serialize an IPAddress? I read it needs to have a default constructor so I made a wrapper class: public class IPAddressEx : IPAddress { public IPAddressEx() : base( IPAddress.None.GetAddressBytes() )
3
4228
by: KBJ | last post by:
Hi, How can I get IP address of client, which sends request to server via .net remoting? Regards, Kate
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...
0
10208
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10038
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...
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
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
5294
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
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.