VB.net and System.Uint32
-
I am try to write a Gnutella client in Vb.net and have hit a road bump. According to the interfaces GetHostIP (Isearch.GetHostIp) which uses the Variables ResultID, HostID, SearchID returns 4 bytes representing the hosts IP. I have tried converting this to a Int32 using Converto.Int32 but I can never get any actual information all I get is 0. Can anyone help with getting a Uint32 value to display in VB.net ultimately it will be displayed in a listview. Cheers in Advance 0pius
-
I am try to write a Gnutella client in Vb.net and have hit a road bump. According to the interfaces GetHostIP (Isearch.GetHostIp) which uses the Variables ResultID, HostID, SearchID returns 4 bytes representing the hosts IP. I have tried converting this to a Int32 using Converto.Int32 but I can never get any actual information all I get is 0. Can anyone help with getting a Uint32 value to display in VB.net ultimately it will be displayed in a listview. Cheers in Advance 0pius
If it's an IP address, wouldn't you want to convert every 8 bits into a number between 0 and 255 ? Have you checked the value you're trying to convert to see what's in it ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
If it's an IP address, wouldn't you want to convert every 8 bits into a number between 0 and 255 ? Have you checked the value you're trying to convert to see what's in it ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Christian, Thanks for your reply. Having never done this (recieved an uint32 or an IP address) could you point me in the right direction. Should I put it into an array, and then reference each byte.
You can use bit masking and bit shifting to get your four bytes out. For example: uint x = 348524; // whatever byte b1 = (x>>24); byte b2 = (x>>16) & 0xFF; byte b3 = (x>>8) & 0xFF; byte b3 =x & 0xFF; That's off the cuff, but it should work.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog