Skip to content
This repository
Browse code

old tcp module is now tcp_old

  • Loading branch information...
commit 663269f6870ca6bf55303f2b1e297e684f9fe768 1 parent 025116f
ry ry authored

Showing 3 changed files with 35 additions and 23 deletions. Show diff stats Hide diff stats

  1. +8 23 lib/tcp.js
  2. +26 0 lib/tcp_old.js
  3. +1 0  src/node.cc
31 lib/tcp.js
... ... @@ -1,26 +1,11 @@
1   -var tcp = process.binding('tcp');
  1 +var net = require('net');
  2 +var sys = require('sys');
2 3
3   -var TLS_STATUS_CODES = {
4   - 1 : 'JS_GNUTLS_CERT_VALIDATED',
5   - 0 : 'JS_GNUTLS_CERT_UNDEFINED',
  4 +var warning;
  5 +if (!warning) {
  6 + warning = "The 'tcp' module is now called 'net'. Otherwise it should have a similar interface.";
  7 + sys.error(warning);
6 8 }
7   -TLS_STATUS_CODES[-100] = 'JS_GNUTLS_CERT_SIGNER_NOT_FOUND';
8   -TLS_STATUS_CODES[-101] = 'JS_GNUTLS_CERT_SIGNER_NOT_CA';
9   -TLS_STATUS_CODES[-102] = 'JS_GNUTLS_CERT_INVALID';
10   -TLS_STATUS_CODES[-103] = 'JS_GNUTLS_CERT_NOT_ACTIVATED';
11   -TLS_STATUS_CODES[-104] = 'JS_GNUTLS_CERT_EXPIRED';
12   -TLS_STATUS_CODES[-105] = 'JS_GNUTLS_CERT_REVOKED';
13   -TLS_STATUS_CODES[-106] = 'JS_GNUTLS_CERT_DOES_NOT_MATCH_HOSTNAME';
14 9
15   -exports.createServer = function (on_connection, options) {
16   - var server = new tcp.Server();
17   - server.addListener("connection", on_connection);
18   - //server.setOptions(options);
19   - return server;
20   -};
21   -
22   -exports.createConnection = function (port, host) {
23   - var connection = new tcp.Connection();
24   - connection.connect(port, host);
25   - return connection;
26   -};
  10 +exports.createServer = net.createServer;
  11 +exports.createConnection = net.createConnection;
26 lib/tcp_old.js
... ... @@ -0,0 +1,26 @@
  1 +var tcp = process.binding('tcp');
  2 +
  3 +var TLS_STATUS_CODES = {
  4 + 1 : 'JS_GNUTLS_CERT_VALIDATED',
  5 + 0 : 'JS_GNUTLS_CERT_UNDEFINED',
  6 +}
  7 +TLS_STATUS_CODES[-100] = 'JS_GNUTLS_CERT_SIGNER_NOT_FOUND';
  8 +TLS_STATUS_CODES[-101] = 'JS_GNUTLS_CERT_SIGNER_NOT_CA';
  9 +TLS_STATUS_CODES[-102] = 'JS_GNUTLS_CERT_INVALID';
  10 +TLS_STATUS_CODES[-103] = 'JS_GNUTLS_CERT_NOT_ACTIVATED';
  11 +TLS_STATUS_CODES[-104] = 'JS_GNUTLS_CERT_EXPIRED';
  12 +TLS_STATUS_CODES[-105] = 'JS_GNUTLS_CERT_REVOKED';
  13 +TLS_STATUS_CODES[-106] = 'JS_GNUTLS_CERT_DOES_NOT_MATCH_HOSTNAME';
  14 +
  15 +exports.createServer = function (on_connection, options) {
  16 + var server = new tcp.Server();
  17 + server.addListener("connection", on_connection);
  18 + //server.setOptions(options);
  19 + return server;
  20 +};
  21 +
  22 +exports.createConnection = function (port, host) {
  23 + var connection = new tcp.Connection();
  24 + connection.connect(port, host);
  25 + return connection;
  26 +};
1  src/node.cc
@@ -1210,6 +1210,7 @@ static Handle<Value> Binding(const Arguments& args) {
1210 1210 exports->Set(String::New("repl"), String::New(native_repl));
1211 1211 exports->Set(String::New("sys"), String::New(native_sys));
1212 1212 exports->Set(String::New("tcp"), String::New(native_tcp));
  1213 + exports->Set(String::New("tcp_old"), String::New(native_tcp_old));
1213 1214 exports->Set(String::New("uri"), String::New(native_uri));
1214 1215 exports->Set(String::New("url"), String::New(native_url));
1215 1216 exports->Set(String::New("utils"), String::New(native_utils));

0 comments on commit 663269f

Please sign in to comment.
Something went wrong with that request. Please try again.