Study Blog

My Study Blog

html5 websocket api data framing in c#

Posted on | October 18, 2011 | No Comments

working on the latest html5 websocket api and developing a html5 websocket server in c#. i spent some time on processing the data frame passed in from the browser in c#. just share it here so someone else might save some time and also might give some thoughts to improve it.

some background.

  1. the latest Websocket IETF draft is draft 17 http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17 (websocket version 8 )
  2. the draft you can play with is draft 10  http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10 (websocket version 8 ) which is build in browser: chrome 14, firefox 7 and IE10 developer preview.
so, to test your websocket server with those brosers, your server better be able to process draft 10 requests(handshake).
when client sends in data or message, the message itself must contain additional framing information so the the server knows how to parse the message. This information typically takes one of the following forms: Delimiter and Explicit length.
in draft 10, data stream passed in from the client used Explicit length method. (The variable-length field or message is preceded by a (fixed-size) length field that tells how many bytes it contains.) refer to http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10#page-24 for detailed description.
my little websocket server will deal with 1 frame masked text data.
you might want to download this pdf to get a better understanding of the first few bytes in a message.
Read more

Block IP address or IP range in windows server 2008 by Windows Firewall

Posted on | October 4, 2011 | 1 Comment

How to Block IP address or IP range in windows server 2008 by Windows Firewall
If you ever feel that someone may be trying to break into your server or know an IP address that you want to block from accessing your server there is a built in firewall on all windows server. You can use this firewall to block either a range of IP addresses or a single address. My server has some suspicious visits, so i decide to block these users.
1. Log into your server via Remote Desktop Connection.
2. Start -> administrative tools > windows firewall with advanced security.
block_ip_windows_server_1
3. On the left side of the firewall window click on the inbound rules option.
4. On the right side of the screen click on New Rule.
5. Click on the custom radio button and then click next.
Read more

NameValueCollection VS Dictionary

Posted on | January 6, 2011 | No Comments

You are considering the NameValueCollection type in the C# programming language. This collection is found in System.Collections.Specialized, and provides a way to map one key to multiple values without custom code. Here we see several examples on NameValueCollection, and then go further and review its use in ASP.NET and benchmark it.

=== NameValueCollection benchmark ===

NameValueCollection lookup: 2768 ms
Dictionary lookup: 407 ms [faster]

Using NameValueCollection

First, we see how you can create a new NameValueCollection. The example then adds four key/value pairs to the collection. The keys can occur more than once, but map to the same array of values. This means you can have one key pointing to two values.

=== Program that uses NameValueCollection (C#) ===

using System;
using System.Collections.Specialized;

class Program
{
static NameValueCollection GetCollection()
{
NameValueCollection collection = new NameValueCollection();
collection.Add(“Sam”, “Dot Net Perls”);
collection.Add(“Bill”, “Microsoft”);
collection.Add(“Bill”, “White House”);
collection.Add(“Sam”, “IBM”);
return collection;
}
Read more

get URL, query string ect.

Posted on | January 5, 2011 | No Comments

string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:1302/TESTERS/Default6.aspx

string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx

string host = HttpContext.Current.Request.Url.Host;
// localhost

//get the the complete querystring part
Uri tempUri = new Uri("http://www.studyblog.net/Default.aspx?fname=kai&lname=dong");
string sQuery = tempUri.Query;
//The 'sQuery' variable would now contain '?fname=kai&lname=dong', which is our query string from the absolut path i did put into my uri object.

//then you can use HttpUtility.ParseQueryString  to put all querystring fields into NameValueCollection
string FName = HttpUtility.ParseQueryString(sQuery).Get("fname");

Read more

Load SCSI hard drive driver without floppy disk while Install windows server 2003 etc.

Posted on | December 23, 2010 | No Comments

while playing with my new toy, a very old HP ProLiant DL360  G4 / G4p, i need to load the scsi hard driver by press F6 while installing windows server 2003, then insert the floppy disk, because the HP ProLiant DL360
G4 uses SCSI U320 hand drive and the scsi driver is not included in Windows server 2003……. -_-!

i dun even remember there’s a thing called Floppy Disk or Diskettes… anyway, i need to work around this.

after a bit search, i found the following solution:

basicly this solution integrate the scsi hard drive driver into your Windows Server installation disk.

  • you’ll need 1 extra software, free of cause.
  • and the scsi driver of cause…

Read more

windows server 2003 Serial Number

Posted on | December 20, 2010 | No Comments

Windows Server 2003 Serial Number

WIN2003 Serial Number

all collected from internet

JCDPY-8M2V9-BR862-KH9XB-HJ3HM

JCBPD-YMX9T-G34HP-PTDWM-CDBQY

JB94R-RDRMF-BR67T-Q8RX6-2MDHM

JCBP6-9D7HT-HGBGB-HMB39-4QGBB

JCGTT-VF8FF-4DQCX-KVBBH-2QKVM

Read more

keep looking »
  • About

    Welcome to my blog. This is something useful for you and me.
  • Categories

  • My Host

  • Meta

  • Useful Links