Raw UDP Adapter – Listener

My previous blog I showed how easy it is to create a UDP broadcast adapter.  The problem with using the soap.udp adapter is that the message is wrapped in a soap envelope.  I tried various way in vain to get around the soap envelope so that I can broadcast or receive messages without the extra fat.  Although for most part it soap envelope would not matter, but just for kicks, I wanted to receive data without soap, I decided to write an adapter.

I followed this tutorial (echo adapter) and made the following changes to include socket connections.  On initialization, I create and bind the socket to the ip and port

listener = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
localEndPoint = new IPEndPoint(IPAddress.Parse(RemoteAddress), RemotePort);
endpoint = (EndPoint) localEndPoint;

On background worker, I open the connection and start listening.

if (IsConnected)
   ReceiveStarted = true;
   while (!StopReciving)
      byte[] data = new byte[1024];
      int receive = listener.ReceiveFrom(data, ref endpoint);
      var receivedData = Encoding.ASCII.GetString(data, 0, receive);
      lock (inboundQueueSynchronizationLock)
          Message requestMessage = Message.CreateMessage(MessageVersion.Default, "UDP/Data",

And basically thats all. Download the full code here.  The zip file includes the code and projects for setup and custom action.

    • Larry Smith
    • June 5th, 2013

    can you please provide what entries are necessary for machine.config?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: