macgyver 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +45 -0
- data/Rakefile +1 -0
- data/assets/MacGap.app/Contents/Frameworks/Growl.framework/Growl +0 -0
- data/assets/MacGap.app/Contents/Frameworks/Growl.framework/Versions/A/Growl +0 -0
- data/assets/MacGap.app/Contents/Frameworks/Growl.framework/Versions/A/Headers/Growl.h +5 -0
- data/assets/MacGap.app/Contents/Frameworks/Growl.framework/Versions/A/Headers/GrowlApplicationBridge.h +551 -0
- data/assets/MacGap.app/Contents/Frameworks/Growl.framework/Versions/A/Headers/GrowlDefines.h +341 -0
- data/assets/MacGap.app/Contents/Frameworks/Growl.framework/Versions/A/Resources/Info.plist +40 -0
- data/assets/MacGap.app/Contents/Frameworks/Growl.framework/Versions/A/_CodeSignature/CodeResources +34 -0
- data/assets/MacGap.app/Contents/Info.plist +48 -0
- data/assets/MacGap.app/Contents/MacOS/MacGap +0 -0
- data/assets/MacGap.app/Contents/PkgInfo +1 -0
- data/assets/MacGap.app/Contents/Resources/_debugger.js +1718 -0
- data/assets/MacGap.app/Contents/Resources/_http_agent.js +310 -0
- data/assets/MacGap.app/Contents/Resources/_http_client.js +533 -0
- data/assets/MacGap.app/Contents/Resources/_http_common.js +222 -0
- data/assets/MacGap.app/Contents/Resources/_http_incoming.js +194 -0
- data/assets/MacGap.app/Contents/Resources/_http_outgoing.js +597 -0
- data/assets/MacGap.app/Contents/Resources/_http_server.js +510 -0
- data/assets/MacGap.app/Contents/Resources/_linklist.js +76 -0
- data/assets/MacGap.app/Contents/Resources/_stream_duplex.js +69 -0
- data/assets/MacGap.app/Contents/Resources/_stream_passthrough.js +41 -0
- data/assets/MacGap.app/Contents/Resources/_stream_readable.js +900 -0
- data/assets/MacGap.app/Contents/Resources/_stream_transform.js +204 -0
- data/assets/MacGap.app/Contents/Resources/_stream_writable.js +456 -0
- data/assets/MacGap.app/Contents/Resources/_tls_legacy.js +887 -0
- data/assets/MacGap.app/Contents/Resources/_tls_wrap.js +831 -0
- data/assets/MacGap.app/Contents/Resources/application.icns +0 -0
- data/assets/MacGap.app/Contents/Resources/assert.js +326 -0
- data/assets/MacGap.app/Contents/Resources/buffer.js +724 -0
- data/assets/MacGap.app/Contents/Resources/child_process.js +1107 -0
- data/assets/MacGap.app/Contents/Resources/cluster.js +613 -0
- data/assets/MacGap.app/Contents/Resources/console.js +108 -0
- data/assets/MacGap.app/Contents/Resources/constants.js +22 -0
- data/assets/MacGap.app/Contents/Resources/crypto.js +691 -0
- data/assets/MacGap.app/Contents/Resources/dgram.js +459 -0
- data/assets/MacGap.app/Contents/Resources/dns.js +274 -0
- data/assets/MacGap.app/Contents/Resources/domain.js +292 -0
- data/assets/MacGap.app/Contents/Resources/en.lproj/Credits.rtf +29 -0
- data/assets/MacGap.app/Contents/Resources/en.lproj/InfoPlist.strings +0 -0
- data/assets/MacGap.app/Contents/Resources/en.lproj/MainMenu.nib +0 -0
- data/assets/MacGap.app/Contents/Resources/en.lproj/Window.nib +0 -0
- data/assets/MacGap.app/Contents/Resources/events.js +312 -0
- data/assets/MacGap.app/Contents/Resources/freelist.js +43 -0
- data/assets/MacGap.app/Contents/Resources/fs.js +1732 -0
- data/assets/MacGap.app/Contents/Resources/http.js +119 -0
- data/assets/MacGap.app/Contents/Resources/https.js +134 -0
- data/assets/MacGap.app/Contents/Resources/module.js +529 -0
- data/assets/MacGap.app/Contents/Resources/net.js +1378 -0
- data/assets/MacGap.app/Contents/Resources/nodelike.js +195 -0
- data/assets/MacGap.app/Contents/Resources/os.js +64 -0
- data/assets/MacGap.app/Contents/Resources/path.js +517 -0
- data/assets/MacGap.app/Contents/Resources/public/index.html +38 -0
- data/assets/MacGap.app/Contents/Resources/punycode.js +507 -0
- data/assets/MacGap.app/Contents/Resources/querystring.js +206 -0
- data/assets/MacGap.app/Contents/Resources/readline.js +1311 -0
- data/assets/MacGap.app/Contents/Resources/repl.js +945 -0
- data/assets/MacGap.app/Contents/Resources/smalloc.js +90 -0
- data/assets/MacGap.app/Contents/Resources/stream.js +127 -0
- data/assets/MacGap.app/Contents/Resources/string_decoder.js +189 -0
- data/assets/MacGap.app/Contents/Resources/sys.js +24 -0
- data/assets/MacGap.app/Contents/Resources/timers.js +568 -0
- data/assets/MacGap.app/Contents/Resources/tls.js +220 -0
- data/assets/MacGap.app/Contents/Resources/tty.js +129 -0
- data/assets/MacGap.app/Contents/Resources/url.js +693 -0
- data/assets/MacGap.app/Contents/Resources/util.js +688 -0
- data/assets/MacGap.app/Contents/Resources/vm.js +73 -0
- data/assets/MacGap.app/Contents/Resources/zlib.js +524 -0
- data/assets/index.html +38 -0
- data/bin/macgyver +104 -0
- data/macgyver.gemspec +19 -0
- data/test/public/index.html +27 -0
- metadata +121 -0
@@ -0,0 +1,459 @@
|
|
1
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
2
|
+
//
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
// copy of this software and associated documentation files (the
|
5
|
+
// "Software"), to deal in the Software without restriction, including
|
6
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
+
// persons to whom the Software is furnished to do so, subject to the
|
9
|
+
// following conditions:
|
10
|
+
//
|
11
|
+
// The above copyright notice and this permission notice shall be included
|
12
|
+
// in all copies or substantial portions of the Software.
|
13
|
+
//
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
17
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
18
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
19
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
20
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
var assert = require('assert');
|
23
|
+
var util = require('util');
|
24
|
+
var events = require('events');
|
25
|
+
|
26
|
+
var UDP = process.binding('udp_wrap').UDP;
|
27
|
+
|
28
|
+
var BIND_STATE_UNBOUND = 0;
|
29
|
+
var BIND_STATE_BINDING = 1;
|
30
|
+
var BIND_STATE_BOUND = 2;
|
31
|
+
|
32
|
+
// lazily loaded
|
33
|
+
var cluster = null;
|
34
|
+
var dns = null;
|
35
|
+
|
36
|
+
var errnoException = util._errnoException;
|
37
|
+
|
38
|
+
function lookup(address, family, callback) {
|
39
|
+
if (!dns)
|
40
|
+
dns = require('dns');
|
41
|
+
|
42
|
+
return dns.lookup(address, family, callback);
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
function lookup4(address, callback) {
|
47
|
+
return lookup(address || '0.0.0.0', 4, callback);
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
function lookup6(address, callback) {
|
52
|
+
return lookup(address || '::0', 6, callback);
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
function newHandle(type) {
|
57
|
+
if (type == 'udp4') {
|
58
|
+
var handle = new UDP;
|
59
|
+
handle.lookup = lookup4;
|
60
|
+
return handle;
|
61
|
+
}
|
62
|
+
|
63
|
+
if (type == 'udp6') {
|
64
|
+
var handle = new UDP;
|
65
|
+
handle.lookup = lookup6;
|
66
|
+
handle.bind = handle.bind6;
|
67
|
+
handle.send = handle.send6;
|
68
|
+
return handle;
|
69
|
+
}
|
70
|
+
|
71
|
+
if (type == 'unix_dgram')
|
72
|
+
throw new Error('unix_dgram sockets are not supported any more.');
|
73
|
+
|
74
|
+
throw new Error('Bad socket type specified. Valid types are: udp4, udp6');
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
exports._createSocketHandle = function(address, port, addressType, fd) {
|
79
|
+
// Opening an existing fd is not supported for UDP handles.
|
80
|
+
assert(!util.isNumber(fd) || fd < 0);
|
81
|
+
|
82
|
+
var handle = newHandle(addressType);
|
83
|
+
|
84
|
+
if (port || address) {
|
85
|
+
var err = handle.bind(address, port || 0, 0);
|
86
|
+
if (err) {
|
87
|
+
handle.close();
|
88
|
+
return err;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
return handle;
|
93
|
+
};
|
94
|
+
|
95
|
+
|
96
|
+
function Socket(type, listener) {
|
97
|
+
events.EventEmitter.call(this);
|
98
|
+
|
99
|
+
var handle = newHandle(type);
|
100
|
+
handle.owner = this;
|
101
|
+
|
102
|
+
this._handle = handle;
|
103
|
+
this._receiving = false;
|
104
|
+
this._bindState = BIND_STATE_UNBOUND;
|
105
|
+
this.type = type;
|
106
|
+
this.fd = null; // compatibility hack
|
107
|
+
|
108
|
+
if (util.isFunction(listener))
|
109
|
+
this.on('message', listener);
|
110
|
+
}
|
111
|
+
util.inherits(Socket, events.EventEmitter);
|
112
|
+
exports.Socket = Socket;
|
113
|
+
|
114
|
+
|
115
|
+
exports.createSocket = function(type, listener) {
|
116
|
+
return new Socket(type, listener);
|
117
|
+
};
|
118
|
+
|
119
|
+
|
120
|
+
function startListening(socket) {
|
121
|
+
socket._handle.onmessage = onMessage;
|
122
|
+
// Todo: handle errors
|
123
|
+
socket._handle.recvStart();
|
124
|
+
socket._receiving = true;
|
125
|
+
socket._bindState = BIND_STATE_BOUND;
|
126
|
+
socket.fd = -42; // compatibility hack
|
127
|
+
|
128
|
+
socket.emit('listening');
|
129
|
+
}
|
130
|
+
|
131
|
+
function replaceHandle(self, newHandle) {
|
132
|
+
|
133
|
+
// Set up the handle that we got from master.
|
134
|
+
newHandle.lookup = self._handle.lookup;
|
135
|
+
newHandle.bind = self._handle.bind;
|
136
|
+
newHandle.send = self._handle.send;
|
137
|
+
newHandle.owner = self;
|
138
|
+
|
139
|
+
// Replace the existing handle by the handle we got from master.
|
140
|
+
self._handle.close();
|
141
|
+
self._handle = newHandle;
|
142
|
+
}
|
143
|
+
|
144
|
+
Socket.prototype.bind = function(/*port, address, callback*/) {
|
145
|
+
var self = this;
|
146
|
+
|
147
|
+
self._healthCheck();
|
148
|
+
|
149
|
+
if (this._bindState != BIND_STATE_UNBOUND)
|
150
|
+
throw new Error('Socket is already bound');
|
151
|
+
|
152
|
+
this._bindState = BIND_STATE_BINDING;
|
153
|
+
|
154
|
+
if (util.isFunction(arguments[arguments.length - 1]))
|
155
|
+
self.once('listening', arguments[arguments.length - 1]);
|
156
|
+
|
157
|
+
var UDP = process.binding('udp_wrap').UDP;
|
158
|
+
if (arguments[0] instanceof UDP) {
|
159
|
+
replaceHandle(self, arguments[0]);
|
160
|
+
startListening(self);
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
|
164
|
+
var port = arguments[0];
|
165
|
+
var address = arguments[1];
|
166
|
+
if (util.isFunction(address)) address = ''; // a.k.a. "any address"
|
167
|
+
|
168
|
+
// resolve address first
|
169
|
+
self._handle.lookup(address, function(err, ip) {
|
170
|
+
if (err) {
|
171
|
+
self._bindState = BIND_STATE_UNBOUND;
|
172
|
+
self.emit('error', err);
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
|
176
|
+
if (!cluster)
|
177
|
+
cluster = require('cluster');
|
178
|
+
|
179
|
+
if (cluster.isWorker) {
|
180
|
+
cluster._getServer(self, ip, port, self.type, -1, function(err, handle) {
|
181
|
+
if (err) {
|
182
|
+
self.emit('error', errnoException(err, 'bind'));
|
183
|
+
self._bindState = BIND_STATE_UNBOUND;
|
184
|
+
return;
|
185
|
+
}
|
186
|
+
|
187
|
+
if (!self._handle)
|
188
|
+
// handle has been closed in the mean time.
|
189
|
+
return handle.close();
|
190
|
+
|
191
|
+
replaceHandle(self, handle);
|
192
|
+
startListening(self);
|
193
|
+
});
|
194
|
+
|
195
|
+
} else {
|
196
|
+
if (!self._handle)
|
197
|
+
return; // handle has been closed in the mean time
|
198
|
+
|
199
|
+
var err = self._handle.bind(ip, port || 0, /*flags=*/ 0);
|
200
|
+
if (err) {
|
201
|
+
self.emit('error', errnoException(err, 'bind'));
|
202
|
+
self._bindState = BIND_STATE_UNBOUND;
|
203
|
+
// Todo: close?
|
204
|
+
return;
|
205
|
+
}
|
206
|
+
|
207
|
+
startListening(self);
|
208
|
+
}
|
209
|
+
});
|
210
|
+
};
|
211
|
+
|
212
|
+
|
213
|
+
// thin wrapper around `send`, here for compatibility with dgram_legacy.js
|
214
|
+
Socket.prototype.sendto = function(buffer,
|
215
|
+
offset,
|
216
|
+
length,
|
217
|
+
port,
|
218
|
+
address,
|
219
|
+
callback) {
|
220
|
+
if (!util.isNumber(offset) || !util.isNumber(length))
|
221
|
+
throw new Error('send takes offset and length as args 2 and 3');
|
222
|
+
|
223
|
+
if (!util.isString(address))
|
224
|
+
throw new Error(this.type + ' sockets must send to port, address');
|
225
|
+
|
226
|
+
this.send(buffer, offset, length, port, address, callback);
|
227
|
+
};
|
228
|
+
|
229
|
+
|
230
|
+
Socket.prototype.send = function(buffer,
|
231
|
+
offset,
|
232
|
+
length,
|
233
|
+
port,
|
234
|
+
address,
|
235
|
+
callback) {
|
236
|
+
var self = this;
|
237
|
+
|
238
|
+
if (util.isString(buffer))
|
239
|
+
buffer = new Buffer(buffer);
|
240
|
+
|
241
|
+
if (!util.isBuffer(buffer))
|
242
|
+
throw new TypeError('First argument must be a buffer or string.');
|
243
|
+
|
244
|
+
offset = offset | 0;
|
245
|
+
if (offset < 0)
|
246
|
+
throw new RangeError('Offset should be >= 0');
|
247
|
+
|
248
|
+
if (offset >= buffer.length)
|
249
|
+
throw new RangeError('Offset into buffer too large');
|
250
|
+
|
251
|
+
// Sending a zero-length datagram is kind of pointless but it _is_
|
252
|
+
// allowed, hence check that length >= 0 rather than > 0.
|
253
|
+
length = length | 0;
|
254
|
+
if (length < 0)
|
255
|
+
throw new RangeError('Length should be >= 0');
|
256
|
+
|
257
|
+
if (offset + length > buffer.length)
|
258
|
+
throw new RangeError('Offset + length beyond buffer length');
|
259
|
+
|
260
|
+
port = port | 0;
|
261
|
+
if (port <= 0 || port > 65535)
|
262
|
+
throw new RangeError('Port should be > 0 and < 65536');
|
263
|
+
|
264
|
+
// Normalize callback so it's either a function or undefined but not anything
|
265
|
+
// else.
|
266
|
+
if (!util.isFunction(callback))
|
267
|
+
callback = undefined;
|
268
|
+
|
269
|
+
self._healthCheck();
|
270
|
+
|
271
|
+
if (self._bindState == BIND_STATE_UNBOUND)
|
272
|
+
self.bind(0, null);
|
273
|
+
|
274
|
+
// If the socket hasn't been bound yet, push the outbound packet onto the
|
275
|
+
// send queue and send after binding is complete.
|
276
|
+
if (self._bindState != BIND_STATE_BOUND) {
|
277
|
+
// If the send queue hasn't been initialized yet, do it, and install an
|
278
|
+
// event handler that flushes the send queue after binding is done.
|
279
|
+
if (!self._sendQueue) {
|
280
|
+
self._sendQueue = [];
|
281
|
+
self.once('listening', function() {
|
282
|
+
// Flush the send queue.
|
283
|
+
for (var i = 0; i < self._sendQueue.length; i++)
|
284
|
+
self.send.apply(self, self._sendQueue[i]);
|
285
|
+
self._sendQueue = undefined;
|
286
|
+
});
|
287
|
+
}
|
288
|
+
self._sendQueue.push([buffer, offset, length, port, address, callback]);
|
289
|
+
return;
|
290
|
+
}
|
291
|
+
|
292
|
+
self._handle.lookup(address, function(ex, ip) {
|
293
|
+
if (ex) {
|
294
|
+
if (callback) callback(ex);
|
295
|
+
self.emit('error', ex);
|
296
|
+
}
|
297
|
+
else if (self._handle) {
|
298
|
+
var req = { buffer: buffer }; // Keep reference alive.
|
299
|
+
if (callback) {
|
300
|
+
req.callback = callback;
|
301
|
+
req.oncomplete = afterSend;
|
302
|
+
}
|
303
|
+
var err = self._handle.send(req,
|
304
|
+
buffer,
|
305
|
+
offset,
|
306
|
+
length,
|
307
|
+
port,
|
308
|
+
ip,
|
309
|
+
!!callback);
|
310
|
+
if (err && callback) {
|
311
|
+
// don't emit as error, dgram_legacy.js compatibility
|
312
|
+
process.nextTick(function() {
|
313
|
+
callback(errnoException(err, 'send'));
|
314
|
+
});
|
315
|
+
}
|
316
|
+
}
|
317
|
+
});
|
318
|
+
};
|
319
|
+
|
320
|
+
|
321
|
+
function afterSend(err) {
|
322
|
+
this.callback(err ? errnoException(err, 'send') : null);
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
Socket.prototype.close = function() {
|
327
|
+
this._healthCheck();
|
328
|
+
this._stopReceiving();
|
329
|
+
this._handle.close();
|
330
|
+
this._handle = null;
|
331
|
+
this.emit('close');
|
332
|
+
};
|
333
|
+
|
334
|
+
|
335
|
+
Socket.prototype.address = function() {
|
336
|
+
this._healthCheck();
|
337
|
+
|
338
|
+
var out = {};
|
339
|
+
var err = this._handle.getsockname(out);
|
340
|
+
if (err) {
|
341
|
+
throw errnoException(err, 'getsockname');
|
342
|
+
}
|
343
|
+
|
344
|
+
return out;
|
345
|
+
};
|
346
|
+
|
347
|
+
|
348
|
+
Socket.prototype.setBroadcast = function(arg) {
|
349
|
+
var err = this._handle.setBroadcast(arg ? 1 : 0);
|
350
|
+
if (err) {
|
351
|
+
throw errnoException(err, 'setBroadcast');
|
352
|
+
}
|
353
|
+
};
|
354
|
+
|
355
|
+
|
356
|
+
Socket.prototype.setTTL = function(arg) {
|
357
|
+
if (!util.isNumber(arg)) {
|
358
|
+
throw new TypeError('Argument must be a number');
|
359
|
+
}
|
360
|
+
|
361
|
+
var err = this._handle.setTTL(arg);
|
362
|
+
if (err) {
|
363
|
+
throw errnoException(err, 'setTTL');
|
364
|
+
}
|
365
|
+
|
366
|
+
return arg;
|
367
|
+
};
|
368
|
+
|
369
|
+
|
370
|
+
Socket.prototype.setMulticastTTL = function(arg) {
|
371
|
+
if (!util.isNumber(arg)) {
|
372
|
+
throw new TypeError('Argument must be a number');
|
373
|
+
}
|
374
|
+
|
375
|
+
var err = this._handle.setMulticastTTL(arg);
|
376
|
+
if (err) {
|
377
|
+
throw errnoException(err, 'setMulticastTTL');
|
378
|
+
}
|
379
|
+
|
380
|
+
return arg;
|
381
|
+
};
|
382
|
+
|
383
|
+
|
384
|
+
Socket.prototype.setMulticastLoopback = function(arg) {
|
385
|
+
var err = this._handle.setMulticastLoopback(arg ? 1 : 0);
|
386
|
+
if (err) {
|
387
|
+
throw errnoException(err, 'setMulticastLoopback');
|
388
|
+
}
|
389
|
+
|
390
|
+
return arg; // 0.4 compatibility
|
391
|
+
};
|
392
|
+
|
393
|
+
|
394
|
+
Socket.prototype.addMembership = function(multicastAddress,
|
395
|
+
interfaceAddress) {
|
396
|
+
this._healthCheck();
|
397
|
+
|
398
|
+
if (!multicastAddress) {
|
399
|
+
throw new Error('multicast address must be specified');
|
400
|
+
}
|
401
|
+
|
402
|
+
var err = this._handle.addMembership(multicastAddress, interfaceAddress);
|
403
|
+
if (err) {
|
404
|
+
throw new errnoException(err, 'addMembership');
|
405
|
+
}
|
406
|
+
};
|
407
|
+
|
408
|
+
|
409
|
+
Socket.prototype.dropMembership = function(multicastAddress,
|
410
|
+
interfaceAddress) {
|
411
|
+
this._healthCheck();
|
412
|
+
|
413
|
+
if (!multicastAddress) {
|
414
|
+
throw new Error('multicast address must be specified');
|
415
|
+
}
|
416
|
+
|
417
|
+
var err = this._handle.dropMembership(multicastAddress, interfaceAddress);
|
418
|
+
if (err) {
|
419
|
+
throw new errnoException(err, 'dropMembership');
|
420
|
+
}
|
421
|
+
};
|
422
|
+
|
423
|
+
|
424
|
+
Socket.prototype._healthCheck = function() {
|
425
|
+
if (!this._handle)
|
426
|
+
throw new Error('Not running'); // error message from dgram_legacy.js
|
427
|
+
};
|
428
|
+
|
429
|
+
|
430
|
+
Socket.prototype._stopReceiving = function() {
|
431
|
+
if (!this._receiving)
|
432
|
+
return;
|
433
|
+
|
434
|
+
this._handle.recvStop();
|
435
|
+
this._receiving = false;
|
436
|
+
this.fd = null; // compatibility hack
|
437
|
+
};
|
438
|
+
|
439
|
+
|
440
|
+
function onMessage(nread, handle, buf, rinfo) {
|
441
|
+
var self = handle.owner;
|
442
|
+
if (nread < 0) {
|
443
|
+
return self.emit('error', errnoException(nread, 'recvmsg'));
|
444
|
+
}
|
445
|
+
rinfo.size = buf.length; // compatibility
|
446
|
+
self.emit('message', buf, rinfo);
|
447
|
+
}
|
448
|
+
|
449
|
+
|
450
|
+
Socket.prototype.ref = function() {
|
451
|
+
if (this._handle)
|
452
|
+
this._handle.ref();
|
453
|
+
};
|
454
|
+
|
455
|
+
|
456
|
+
Socket.prototype.unref = function() {
|
457
|
+
if (this._handle)
|
458
|
+
this._handle.unref();
|
459
|
+
};
|