Re: IPAddress.Address is negative
From: Milosz - [playseven.com] (mw_at_playseven.com)
Date: 02/20/04
- Next message: Jon Skeet [C# MVP]: "Re: IMPORTANT: OpenNETCF Smart Device Framework -- Re-install dialog during deploy"
- Previous message: Mark: "Re: Weird Webservice and .net cf problem - please help"
- In reply to: Chris Tacke, eMVP: "Re: IPAddress.Address is negative"
- Next in thread: Milosz - [playseven.com]: "LSB"
- Reply: Milosz - [playseven.com]: "LSB"
- Reply: Kevin Hutchison: "Re: IPAddress.Address is negative"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 20 Feb 2004 14:19:23 +0100
I'm sorry. I do not understand.
IPAdress.Adress is signed becouse it's a simple Int32, and IcmpSendEcho
wants to have an unsigned int.
What is an LSB and how to uncheck it?
Do you mean i have to pass the long value 'as it is' to IcmpSendEcho
Function ?
regards
Milosz
"Chris Tacke, eMVP" <ctacke[at]Open_NET_CF[dot]org> schrieb im Newsbeitrag
news:eq4%23AV69DHA.2308@TK2MSFTNGP11.phx.gbl...
> With unsigned numbers there is no such thing as negative. It simply means
> that your LSB is on. If you use unchecked you can stuff a "negative"
signed
> number into an unsigned.
>
> -Chris
>
> "Milosz - [playseven.com]" <mw@playseven.com> wrote in message
> news:u$uS6N69DHA.2804@TK2MSFTNGP09.phx.gbl...
> > Hello,
> >
> > I perform a ping using the IcmpSendEcho Function from iphlpapi:
> > <DllImport("iphlpapi")> _
> >
> > Private Shared Function IcmpSendEcho(ByVal IcmpHandle As IntPtr, ByVal
> > DestinationAddress As System.UInt32, ByVal RequestData() As Byte, ByVal
> > RequestSize As Integer, ByVal RequestOptions As IntPtr, ByVal
> ReplyBuffer()
> > As Byte, ByVal ReplySize As Int32, ByVal Timeout As Int32) As
> System.UInt32
> >
> >
> > This Function requires a Destination Adress as an unsigned Int32. I get
it
> > from the IPAddress.Address Object.
> >
> > Public Structure PingOptions
> > Dim IPAdress As IPAddress
> > Dim TimeOUT As Integer
> > End Structure
> > dim opt as PingOptions
> >
> > opt.IPAdress = IPAddress.Parse("192.168.1.128") ' Adresses bigger then
> > A.B.C.127, have a negative adress value !!!
> >
> > ipaddr = System.UInt32.Parse(opt.IPAdress.Address) ' and couse exception
> > here
> >
> > Dim ret As System.UInt32
> >
> > 'but i need an unsigned int here in the second parameter
> > ret = IcmpSendEcho(h, opt.ipaddr, RequestData, CInt(RequestData.Length),
> > IntPtr.Zero, reply._Data, reply._Data.Length, opt.TimeOUT)
> >
> > The Problem is that for IPAdresses, where the last Byte is bigger then
> 127.
> > the generated Long Value for Adress is negative and the Parse Method to
> the
> > uint32 couses an exception.
> >
> > Or should i declare the DestinationAdress as Long in the IcmpSendEcho
and
> > put in IPAdress.Address value directly.
> > My assumption is that the Address value is created in the correct
> bitformat
> > but becouse the CF is declaring it as a long it is interpreted negative.
> >
> > Or how else to get the correct Long Value from IPAdress.Address ?
> >
> > THX in advance
> >
> >
> > --
> > -> Milosz Weckowski
> > www.playseven.com
> >
> > mailto:mw@playseven.com
> > ICQ Number: 84867613
> >
> > Get the enhanced Progressbar and a fine Colorpicker for the Compact
> Framwork
> > for free:
> > http://www.playseven.com/11620/p7_Controls.html
> >
> >
>
>
- Next message: Jon Skeet [C# MVP]: "Re: IMPORTANT: OpenNETCF Smart Device Framework -- Re-install dialog during deploy"
- Previous message: Mark: "Re: Weird Webservice and .net cf problem - please help"
- In reply to: Chris Tacke, eMVP: "Re: IPAddress.Address is negative"
- Next in thread: Milosz - [playseven.com]: "LSB"
- Reply: Milosz - [playseven.com]: "LSB"
- Reply: Kevin Hutchison: "Re: IPAddress.Address is negative"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|