-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathserver.js
More file actions
34 lines (25 loc) · 651 Bytes
/
server.js
File metadata and controls
34 lines (25 loc) · 651 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
32
33
34
var fs = require('fs');
var net = require('net');
var that = this;
this.server = net.createServer();
this.server.on('connection', function(socket) {
var sync = fs.createReadStream('./libtest.dylib');
console.log('new Connection : ', socket.remoteAddress);
socket.on('error', function (err) {
socket.end();
});
sync.on('error', function(e) {
});
sync.on('open', function() {
sync.pipe(socket);
});
sync.on('finish', function() {
socket.end();
});
});
this.server.on('error', function (err) {
throw err;
});
this.server.listen(1234, function() {
console.log(' Started on port : ', that.server.address().port);
});