• Stars
    star
    172
  • Rank 220,185 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 14 years ago
  • Updated about 13 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Node.net - Node.js implemented in Javascript on the .NET runtime

Goals

  • Same theory of operation as Node.js (single threaded eventing front-end, non-blocking IO back-end)
  • API compatibility with Node.js
  • Written entirely in Javascript (JScript.NET)
  • Runs on the .NET runtime

What is implemented

  • Enough of the `http' module to implement a basic server that handles post data and sends back response
  • Enough of the `net' module to implement a TCP server that echoes requests to stdout
  • Enough of the `stream' api to support the above -require() -sys.puts()

Limitations

HTTP requests are cached by .NET even though the stream is read async. This was a limitation of using HttpListener in .NET. The TCP server is fully streaming however. Writes are implemented as blocking calls currently. I didn't have time to implement write queues to enforce write ordering.

Usage

On Windows:

If you have the .NET 2.0 framework installed (likely if you are on a Windows box), just run the build script. If you'd rather build against a different framework version, you can alter the path to jsc.exe.

C:\> node.exe server.js

On Linux, under Mono:

C:\> mono node.exe server.js

In order to run under Mono, you'll need Microsoft's version of Microsoft.JScript.dll, which is included in the .NET framework. I can't provide it here since it is not redistributable individually.

Examples

Running an HTTP server that prints post data to the console and replies with an `All finished' message when the request completes:

var sys = require( 'sys' ), http = require( 'http' );
http.createServer( function( request, response ) {
	request.addListener( 'data', function( data ) {
		sys.puts( data );
	});
	request.addListener( 'end', function() {
		response.write( '<html><body><p>All finished!<p></body></html>' );
		response.end();
	});
}).listen( 9981, 'localhost' );

To test it out, try something like this:

C:\>curl http://localhost:9981 -d "hello"
<html><body><p>All finished!<p></body></html>

Running a TCP server that listens on port 9982 and writes data sent to the console:

var sys = require( 'sys' ), net = require( 'net' );
net.createServer( function( stream ) {
	stream.addListener( 'data', function( data ) {
		sys.puts( data );
	});
}).listen( 9982, 'localhost' );

To test out the TCP server try sending it some data using telnet:

C:\>telnet localhost 9982

The .NET framework can be accessed from within the Javascript that runs under Node.net. For example, the TCP server shown above could have used Console.WriteLine() in order to write its output to the console:

var net = require( 'net' );
net.createServer( function( stream ) {
	stream.addListener( 'data', function( data ) {
		System.Console.WriteLine( data );
	});
}).listen( 9982, 'localhost' );

Building from source

On Windows:

C:> build.bat

On Linux

Mono's mjs compiler doesn't compile Node.net.

Future work

  • Implement non-blocking writes
  • HTTP implementation should be rewritten to use the `net' module to allow streaming
  • Implement more of the Node.js API (filesystem, process, etc.)

License

Node.js is provided under the MIT free software license. See the file LICENSE for the full text. Copyright 2010 Dan Newcome

More Repositories

1

Donatello

Pure-CSS drawing library for the browser.
JavaScript
368
star
2

jath

Jath is a simple template language for parsing xml using json markup.
JavaScript
68
star
3

node-libpd

C
22
star
4

jstle

Jstle is a terse javascript RDF serialization language
JavaScript
15
star
5

richie

Richie is a Javascript rich text editor for mobile and desktop browsers
JavaScript
14
star
6

crmQuery

CrmQuery is a tiny domain-specific language for building queries against Microsoft Dynamics CRM inspired by jQuery and SQL
C#
9
star
7

js-xml-serializer

JS to XML serialization with XML namespaces support
JavaScript
5
star
8

http-parser-net

Managed .NET wrapper for http-parser (node.js http parser)
C
5
star
9

Comet-server-for-ASP.NET

Simple http server-push registration using async http handlers in ASP.NET
C#
4
star
10

react-dual-rangeslider

Semantic dual range slider component for Reactjs
JavaScript
4
star
11

amazon-simpledb-cli

Fork of Eric Hammond's simpledb-cli client
Perl
4
star
12

dub-siren

Node.js dub siren
JavaScript
4
star
13

ic-blaster

IC Blaster is a commandline interface for the GIICM integrated circuit database
JavaScript
3
star
14

webpipes

command pipelines for the web
JavaScript
3
star
15

flog

Super-simple threadsafe file logging for .NET
C#
3
star
16

util-scripts

Shell scripts and other small one-off utilities
Vim Script
3
star
17

news.js

node.js news site modeled after news.arc
JavaScript
3
star
18

hn-plonk

Plonk/Killfile script for Hacker News
JavaScript
2
star
19

zpm

Zero-configuration package manager
Shell
2
star
20

dormitory

Dormitory is a zero-config dynamic ORM
C#
2
star
21

sqlson

Template-based query language for Node/MySQL
JavaScript
2
star
22

algoloop

Algorithmic music with JS
JavaScript
2
star
23

batbelt

Simple utility bootstrapping for Windows
Visual Basic
2
star
24

shellstep

Single step through shell scripts interactively line by line
Shell
2
star
25

pyscraper

Declarative python web scraper
Python
2
star
26

pygamesystem

Emulated game system and dev toolchain using pygame
Python
1
star
27

js-xmlwriter

Sequential forward-only XML writer for Javascript
JavaScript
1
star
28

boilerplate

JavaScript
1
star
29

grainjs

JavaScript
1
star
30

acodeaboutblog

A code about blog
C
1
star
31

Djn.Commons

Library of shared .NET code used in some of my projects
C#
1
star
32

pyrenthesis

Little lisp in Python
Python
1
star
33

dojo-fit

Fitness tracker for ad-hoc Dojo workouts
Python
1
star
34

tiny-popup

Minimal robust Javascript pop-up dialog
CSS
1
star
35

eu-chat

EarnUp Chat
JavaScript
1
star
36

pd-skratchpad

Vinyl controlled scratcher/looper for Pure Data
Pure Data
1
star
37

plastik-rock

Guitar Hero/Rock Band controller patch for Pure Data
Pure Data
1
star
38

FakeCRM

Test-double implementation of Microsoft CRM services
C#
1
star
39

padslayer

Two swords technique for the APC20
JavaScript
1
star
40

glfo

Live video performance framework for PD/GEM
Pure Data
1
star
41

dnewcome.github.com

1
star
42

fest

Fest is a simple embedded testing tool for .NET
C#
1
star