public void ProcessRequest(HttpContext context) { HttpResponse Response = context.Response; DateTime startDate = DateTime.Now; Response.ContentType = "text/event-stream"; try { clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress ipAddress = IPAddress.Parse("127.0.0.1"); //Server is listening on port 1000 IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, 1000); //Connect to the server clientSocket.BeginConnect(ipEndPoint, new AsyncCallback(OnConnect), null); } catch (Exception ex) { // MessageBox.Show(ex.Message, "SGSclient", MessageBoxButtons.OK, MessageBoxIcon.Error); } for (int i = 0; i < 50; i++) { try { Response.Write(string.Format("data: {0}\n\n", i)); System.Threading.Thread.Sleep(100); Response.Flush(); } catch { } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)