473,574 Members | 3,052 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IPEndPoint Question

Hi NG,

what is wrong with the following code?
Sender and Revceiver are of the Type IPEndPoint.

//=============== ==
bool IsEqual = tlg.Receiver.Eq uals(aTlg.Sende r);
if(tlg.Receiver .Address == aTlg.Sender.Add ress)
{
if(tlg.Receiver .Port == aTlg.Sender.Por t)
{
}
}
//=============== ==
I have the situation, where IsEqual is true, but the first if - block is
never entered. Why ist that?
If I look at tlg.Reciever.Ad dress, the debugger shows me the same value as
with aTlg.Sender.Add ress!

What is it that I miss here?

Thanks for hep and hints.
Rainer
Jan 23 '06 #1
4 3835
> bool IsEqual = tlg.Receiver.Eq uals(aTlg.Sende r);
Performs the checks of the address and port, why do you do it additionaly?

Also IPAddress contains not only address, but also address family.

Try to call
if ( tlg.Receiver.Ad dress.Equals(aT lg.Sender.Addre ss) )
{
...
}

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

"Rainer Queck" <Ra****@noemail .noemail> wrote in message
news:ue******** *****@TK2MSFTNG P15.phx.gbl...
Hi NG,

what is wrong with the following code?
Sender and Revceiver are of the Type IPEndPoint.

//=============== ==
bool IsEqual = tlg.Receiver.Eq uals(aTlg.Sende r);
if(tlg.Receiver .Address == aTlg.Sender.Add ress)
{
if(tlg.Receiver .Port == aTlg.Sender.Por t)
{
}
}
//=============== ==
I have the situation, where IsEqual is true, but the first if - block is
never entered. Why ist that?
If I look at tlg.Reciever.Ad dress, the debugger shows me the same value as
with aTlg.Sender.Add ress!

What is it that I miss here?

Thanks for hep and hints.
Rainer

Jan 23 '06 #2
Hi Vadym,
bool IsEqual = tlg.Receiver.Eq uals(aTlg.Sende r); Performs the checks of the address and port, why do you do it additionaly?

This line was not there from the beginning. I added just for debugging.
The problem is, that the if-block was never entered.
Also IPAddress contains not only address, but also address family. In my case the address family should be identical, since I am using two
instances of the same class, to send UDP telegrams to each other, or not?
Try to call
if ( tlg.Receiver.Ad dress.Equals(aT lg.Sender.Addre ss) )

Actually I am now using :
bool IsEqual = tlg.Receiver.Eq uals(aTlg.Sende r);
if (IsEqual)....
to veryfy whether the the telgram received is a answer to the one sent
befor...

I am still confused, why my if (..) did not work.

Regards
Rainer
Jan 23 '06 #3
IPEndPoint doesn't have "==" operator overriden.
If it is not overriden object references are compared, since you're
comparing 2 different objects their references are also different.

That is for IpEndPoint and IPAddress we need to use Equals method to check
their equality

IPEndPoint ipEndP1 = new IPEndPoint(IPAd dress.Parse("19 2.168.10.73"), 10);
IPEndPoint ipEndP2 = new IPEndPoint(IPAd dress.Parse("19 2.168.10.73"), 10);

if (ipEndP1 == ipEndP2)
Console.WriteLi ne("Equal with ==");
else if ( ipEndP1.Equals( ipEndP2) )
Console.WriteLi ne("Equal with Equals method");
else
Console.WriteLi ne("not equal");

if ( ipEndP1.Address == ipEndP2.Address )
Console.WriteLi ne("Equal with ==");
else if ( ipEndP1.Address .Equals(ipEndP2 .Address) )
Console.WriteLi ne("Equal with Equals method");
else
Console.WriteLi ne("not equal");

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com
Jan 23 '06 #4
Hi Vadym,

"Vadym Stetsyak" <va*****@ukr.ne t> schrieb im Newsbeitrag
news:Oh******** *****@TK2MSFTNG P15.phx.gbl...
IPEndPoint doesn't have "==" operator overriden.
If it is not overriden object references are compared, since you're
comparing 2 different objects their references are also different.

That is for IpEndPoint and IPAddress we need to use Equals method to check
their equality

Now I see. Thank you for your help!

Regards
Rainer
Jan 23 '06 #5

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

Similar topics

3
5019
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
2647
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask it differently. FOUR QUESTIONS: The background: I got three (3) files
3
3074
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table before rowID answID qryrow questionID datafield 1591 12 06e 06e 06e question 1593 12 06f 06f 06f question 1594 12 answer to the question 06f
0
1242
by: Tim Mavers | last post by:
I am trying to use the ANTS Profiling service to profile a .NET web app (on my machine). I have XP SP2 with the Firewall turned off (my company's security policy sets this). I have talked to ANTS support, but they have no idea. The service is running and listening on port 8087 (as expected). I have tried connected with localhost, my...
10
3408
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a database or continue to process on to the next page. I am now trying to learn ASP to see if we can replace some of our applications that were written in...
4
5683
by: James Proctor | last post by:
Hi there, im trying to write a application that has some socket stuff in. Ive only don socket stuff in vb 6 before. In .net i was using IPEndPoint and i want to enter an ip address and port like so: IPEndPoint = New IPEndPoint("192.0.0.01",1000) But its asking for the IPaddress to be a long. How do i convert it or put in an IP address of...
1
4367
by: BadOmen | last post by:
Hi, This is used in a FAQ and it works fine wile connecting to my computer but I want to connect to an other... Original code: Code: Private _IpEndPoint As New IPEndPoint(Dns.GetHostByName(Dns.GetHostName).AddressList(0), 5124)
10
3699
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server Error in '/QuickStartv20' Application. -------------------------------------------------------------------------------- Configuration Error...
53
4041
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
0
7841
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...
0
8105
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. ...
0
8137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6514
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...
1
5657
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...
0
5336
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...
1
2274
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
1
1369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1101
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...

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.