Skip to content

Instantly share code, notes, and snippets.

@mjul
Created March 28, 2011 14:57
Show Gist options
  • Save mjul/890616 to your computer and use it in GitHub Desktop.
Save mjul/890616 to your computer and use it in GitHub Desktop.
Publish a HTML5 Server-Sent Event to a local Kaazing WebSocket Gateway server via UDP from C#
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Test.Playground
{
[TestClass]
public class KaazingPublishTest
{
public void Publish(String message)
{
var host = new IPAddress(new byte[] { 127, 0, 0, 1 });
var port = 50505;
var udpClient = new UdpClient();
var ipEndPoint = new IPEndPoint(host, port);
Byte[] bytes = Encoding.Unicode.GetBytes(message);
udpClient.Send(bytes, bytes.Length, ipEndPoint);
}
[TestMethod]
public void PublishMessage()
{
Publish("Hello from .NET");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment