forked from mafintosh/turbo-net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (19 loc) · 754 Bytes
/
index.js
File metadata and controls
31 lines (19 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const Server = require("./lib/server");
const Connection = require("./lib/connection");
exports.Server = Server;
exports.Connection = Connection;
exports.createServer = function createServer(opts, onconnection) {
if (typeof opts === "function") return exports.createServer(undefined, opts);
const server = new Server(opts);
if (onconnection) server.on("connection", onconnection);
return server;
};
exports.connect = function connect(port, host, opts) {
if (typeof host !== "string" && host)
return exports.connect(port, null, host);
if (!opts) opts = {};
var connection = new Connection();
if (opts.allowHalfOpen) connection.allowHalfOpen = true;
connection._connect(port, host || "127.0.0.1");
return connection;
};