473,756 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get IPaddress's long value

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
parameter in
UdpServer.Recei ve(ref remoteIpEndPoin t);

Thanks a lot in advance!
Ryan
Dec 12 '06 #1
2 3122
have you check out the IPAdress class in the framework it has a some
functions for manipulating address:

System.IPAddres s

Hope this helps

Ollie Riches

"Ryan Liu" <ad********@onl ine.sh.cnwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
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
parameter in
UdpServer.Recei ve(ref remoteIpEndPoin t);

Thanks a lot in advance!
Ryan


Dec 12 '06 #2

Use IPAddress.Parse .
public static void Receive(ref IPEndPoint remoteEndPoint) {
IPAddress target = IPAddress.Parse ("127.0.0.1" );
if (!remoteEndPoin t.Address.Equal s(target)) {
return;
}
// rest of method here
}
Of course you should cache the target endpoint and not parse it every
time, but the above explains what's needed.

HTH,

Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

"Ryan Liu" <ad********@onl ine.sh.cnwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
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
parameter in
UdpServer.Recei ve(ref remoteIpEndPoin t);

Thanks a lot in advance!
Ryan
Dec 12 '06 #3

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

Similar topics

10
6779
by: Michael Riggio | last post by:
Does anyone know why this property is obsolete? Also, is there an alternative available?
6
7209
by: ed | last post by:
What is the difference between IPAddress::Any and IPAddress::Broadcast when being using by a TCPListener class?
2
1795
by: MG | last post by:
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=IPAddress.Parse("1.2.3.4"); byte lBytes=lAddress.GetAddressBytes(); IPAddress lNewAddress=new IPAddress(lBytes);
5
11435
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
15086
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
1
1281
by: Hobbs | last post by:
Suppose I have an ip number such as 10.11.12.13 and I want to change the 13 to 14 how do I do that? For example, I have Dim ip As System.Net.IPAddress ' code to assign a value to 'ip'
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
5756
by: ghost1 | last post by:
I'm wanting to use an app.config file to set the port and IpAddress for a custom server. The problem is that I can't seem to get the Ip into the program. Here is my code... <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="port" value="500" /> <add key="ipadd" value ="173.31.1.125" /> </appSettings>
3
4227
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
9431
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
9844
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
9819
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
8688
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...
1
7226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6514
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
5289
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3326
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2647
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.