Skip to content

Instantly share code, notes, and snippets.

@johnsheehan
Created April 29, 2010 05:43
Show Gist options
  • Save johnsheehan/383198 to your computer and use it in GitHub Desktop.
Save johnsheehan/383198 to your computer and use it in GitHub Desktop.
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Diagnostics;
using System.Threading;
namespace LongPolling
{
class MainClass
{
public static void Main (string[] args)
{
var http = (HttpWebRequest)WebRequest.Create("http://chirpstream.twitter.com/2b/user.json");
http.Method = "GET";
http.Credentials = new NetworkCredential("twitterusername", "twitterpassword");
http.Timeout = -1;
var response = http.GetResponse();
var stream = response.GetResponseStream();
StreamReader sr = new StreamReader(stream);
Stopwatch watch = new Stopwatch();
watch.Start();
while (true) {
var line = sr.ReadLine();
Console.WriteLine ("{0}: {1}", watch.Elapsed.TotalSeconds, line);
Thread.Sleep(1000);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment