Tuesday, November 22, 2011

Long Running HTTP

Typically, an HTTP request is made and returns more or less immediately. But what if you want to keep the connection open so that the server can push data to the client on demand? Traditionally, this is impossible to do, hence the 'pull' nature of web browsers.

There is a solution, however. HTTP allows for a 'chunked' connection. This basically says, keep listening for some unknown amount of data until the end command is sent. This is referred to as long running HTTP, reverse ajax, comet, HTTP push, etc. This allows for real-time communication between the client and server. Unfortunately, with a traditional web server like IIS, these long running requests hold on to their resources and eventually bog down or crash the server.

There are solutions that exist, most of which suggest implementing a stand alone server. There is a protocol called Bayeux that many implementations use that would allow a proprietary client or server work with other proprietary systems implementing it. Others write their own implementations.

In short, it is possible to have real-time communications over HTTP. More and more web applications are beginning to adopt this technique (you have probably used one without knowing it). The major downfall, currently, is the sparseness of open and stable out of the box implementations (especially in .Net and for IIS).

Resources

Comet

Bayeux Protocol

CometD - Javascript Bayeux client backed by Dojo (Bayeux creator) with jQuery bindings

aspComet - Free open Bayeux server

Pokein - Paid .Net server and jQuery friendly client custom implementation (not Bayeux)

WebSync - Paid IIS .Net Bayeux server

Thursday, April 22, 2010

A Few New Things In .Net 4 & C# 4

Tuple

http://msdn.microsoft.com/en-us/library/dd414846.aspx

http://msdn.microsoft.com/en-us/library/system.tuple.aspx

Basically a better option than using object[] in some scenarios (Tuple elements are typed).

Useful For

· Creating arbitrarily sized sets of individually typed elements (can be longer than 8, just tricky).

· Creating functions with multiple return values.

· Create simple structs/classes on the fly.

· Pass multiple parameters in a single one (e.g. Thread.Start(Object)).

MEF

http://msdn.microsoft.com/en-us/library/dd235164(v=VS.100).aspx

http://mef.codeplex.com/

Used to make plug-ins.

(Also note the similar preexisting alternative, MAF, in the System.Addin namespace).

DynamicObject

http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject(v=VS.100).aspx

This is the guy responsible for all of the dynamic keyword magic. You can subclass this to create your own dynamic objects (e.g. all properties on your object can dynamically be mapped to xml elements).

ExpandoObject

http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject(v=VS.100).aspx

This is the guy that you can add members to dynamically.

Named & Optional Parameters

http://www.dotnetcube.com/post/Overview-of-NET-40-features-e28093-C-40-Named-and-Optional-Parameters.aspx

Yay, C# has optional parameters now!

Parallelism

http://www.danielmoth.com/Blog/parallelising-loops-in-net-4.aspx

Getting fancy with threading syntax.

Task

http://msdn.microsoft.com/en-us/library/system.threading.tasks.task.aspx

http://www.danielmoth.com/Blog/New-And-Improved-CLR-4-Thread-Pool-Engine.aspx

http://www.danielmoth.com/Blog/Introducing-The-New-Task-Type.aspx

Super threading (thread pool enhancements).

Exception Handling Changes

http://geekswithblogs.net/sdorman/archive/2008/11/07/clr-4.0-corrupting-state-exceptions.aspx

Boring… but probably very important to know.

Tuesday, April 13, 2010

.net All-In-One Code Framework

Delineates the framework and skeleton of Microsoft development techniques through typical sample codes in three popular programming languages (Visual C#, VB.NET, Visual C++).

Basically a collection of samples for many of the APIs within the .Net Framework.



OpenRasta

OpenRasta is a resource-oriented framework for .NET enabling easy ReST-ful development of web sites and services.

Provides a Resources-Handlers-Codecs model similar to Model-View-Controller for serving up resources via URIs.

Project Home

cURL

"curl is a command line tool for transferring data with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS, FILE, IMAP, SMTP, POP3 and RTSP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, kerberos...), file transfer resume, proxy tunneling and a busload of other useful tricks"

Common Uses - www screen scraping & programatic form submissions; creating high level APIs for websites without having low level access.



Introduction

Hello! I am Troy Ingram. This is a place where I will keep a collection of 'extras'. That is, miscellaneous information that I come across on the web that I would like to log for later use. I hope that these resources will be helpful and interesting for you as well.

This is a companion blog to Coding Box.