Archive for the 'UDP Communication' Category

C, Source Code, UDP Communication

UDPListener: Receiving UDP messages in C#

This post is part of the UDPCommunication project.

UDP - User Datagram Protocol

The class in this post allows, in an easy and fast manner, to receive UDP messages. You don’t need to be a socket expert to use the class, cause you only need to write few rows of code to use it. Following, a little example showing how to use the class:

private void InitConnection()
{
	m_udpListener = new UDPListener(m_port, new byte[4] { 0, 0, 0, 0 });
	m_udpListener.MessageReceived += new UDPMessageReceivedDelegate(udpListener_MessageReceived);
}

Continue Reading »

C, Source Code, UDP Communication

UDPSender: Sending UDP messages in C#

This post is part of the UDPCommunication project.

Header UDP

This is a class that allows to send UDP messages in C# with an unbelievable semplicity.
To create the class you only need to create it, specifying a port for the udp communication, eg 3125 in this case:

try
{
	INetworkSender udpSender = new UDPSender(3125)
}
catch(UDPSenderException e)
{
        	// error during the socket initialization
}

Sending a message to an host is simple: call the SendMessage method specifying the receiver (with an host name, like “www.coders4fun.com“, or with an ip, like “192.168.10.6“) and a byte array containing the message.
Continue Reading »