473,465 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

UDPClient.Send Checking

Hi ,

I need help on this one.. any help would be appreciated, heres my code:

My code for sending using UDPClient:

public void Send( string Message)
{
if ( !isRunning ) return ;
try
{
byte[] bs = System.Text.Encoding.UTF8.GetBytes(Message);
thisClient.Send(bs,(int) bs.Length, RemoteEndPoint);
}
catch(Exception e)
{
if(OnError!=null)
OnError("Error Sending: " + e.Message);
done = true;
isRunning = false;
}
Thread.Sleep(100);
}

My code for Listen():

private void Listen()
{
done = false;
while(!done)
{
try
{
IPEndPoint IPEndPointNull = new IPEndPoint( IPAddress.Any,
this.mygroupPort );
byte[] bs = thisClient.Receive( ref
IPEndPointNull);
string msg = System.Text.Encoding.UTF8.GetString(bs,0,bs.Length );
if ( OnRecieve != null )
OnRecieve(msg);
}
catch(Exception e)
{
if(OnError!=null)
OnError("Error Recieving: " + e.Message);
done = true;
isRunning = false;

}
}
}
Problem:

How can i check if the one i sent is correctly received by the listener and
how i pass back to the send() telling it that the message sent was not right
needs to retry sending? and how i do check if the listener did not receive
the message sent? any idea? i really would appreciate any help..thanks
Oct 21 '06 #1
2 3100
Hi Rain,
How can i check if the one i sent is correctly received by the listener
...
afaik there exists the OSI model that ensures correct transport through
several layers

http://en.wikipedia.org/wiki/OSI_model

that means the layer below the UDP, the IP, is already checking for
correctness.

If you don't want to trust that, you can use the TCP protocol (TCPClient)
this is a connection-oriented protocol that ensures the receiving of the
message (and it should be correct).

Also you can add same additional data to your message, such as a checksum or
other, e.g. XOR every char (of your message) and append the result to the
message, so you can check this on the other side. (by the way, the lower
levels also check with checksums, so it would be twice or more often)

... and
how i pass back to the send() telling it that the message sent was not
right
needs to retry sending? ...
Use TCP, or build your own protocol basing on UDP. (choose a word that marks
the kind of message: e.g. RTY or ACK)
... and how i do check if the listener did not receive
the message sent?
with UDP it's not possible to check this, it sends the message into the
cable and forgets everything about it.
And how should the destiny realize that there should be something to
receive? - So use TCP
I hope all is right and can help you. (my first post in Newsgroups)

Greets
Franz
Oct 21 '06 #2
that means the layer below the UDP, the IP, is already checking for
correctness.
Actually that's not entirely correct. UDP is a protocol that does not
perform checking and it does not assure that packets arrive in
sequence. You need to either use a sort of acknowledgement process by
sending ACK's back and forth to make sure the packets arrive or if you
do not really need to use UDP, then use TCP. THat does guarantee
delivery and in order.

--
http://www.hadihariri.com
http://www.malagadnug.org
Oct 21 '06 #3

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

Similar topics

0
by: Stephan Steiner | last post by:
Hi The project I'm currently working on involves sending large UDP broadcasts. As the .NET framework already provides an easy facility for sending and receiving UDP packets I thought it was a...
1
by: Dan Kelley | last post by:
I have 2 projects - 1 Winform project that sends Udp messages using the UdpClient class when a button is clicked, and a Console application that listens for these Udp messages. If I try to use...
2
by: Rick | last post by:
Hi, I'm trying to get a simple UdpClient app working. I've been looking at the MSDN info regarding UdpClient. When I set it up on my own PC and send messages to myself it works OK. If I try to...
0
by: Steve | last post by:
I am looking into UdpClient sample code from MSDN where one UdpClient object used for both send and receive operation. Please take a look at the link below...
2
by: Emilio | last post by:
Question about UdpClient sample ' This constructor arbitrarily assigns the local port number. Dim udpClient As New UdpClient() Try udpClient.Connect("www.contoso.com", 11000) ' Sends a...
1
by: Peter Krikelis | last post by:
Hi, I am trying to build a SNMP application using VB .NET. I am using the udpClient class to send and receive data. The SNMP header when viewed in hex looks like :: 7E 05 13 C1 ........ 7E ...
3
by: D. André Dhondt | last post by:
In VB.NET 2003, is there a way to create a System.Net.Sockets.UDPClient to listen to any address AND any port? I can get it to listen to any address, but only if I specify a port (for example,...
0
by: matt | last post by:
Hi I built a class to poll an app on a udp port using the sync methods which worked fine. I've since changed to using beginreceive and now the poll works but I don't receive the response from...
7
by: | last post by:
I have the following program using System; using System.Collections; using System.Net.Sockets; using System.Net; using System.IO; public class Test { public static void Main(string s) {
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.