summaryrefslogtreecommitdiff
path: root/lib/net.js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-03-12 13:04:33 -0800
committerRyan Dahl <ry@tinyclouds.org>2010-03-12 13:06:05 -0800
commitaa6eaae0aa8ba46ca2a25bd0b1e8eec5498df847 (patch)
tree69aae78a372815fc289a8982d3f247baab2e6816 /lib/net.js
parentb571900d9ccf4d7f64bfa31a6920bdbdcbe45b64 (diff)
downloadnode-new-aa6eaae0aa8ba46ca2a25bd0b1e8eec5498df847.tar.gz
Simplify Socket constructor
Diffstat (limited to 'lib/net.js')
-rw-r--r--lib/net.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/net.js b/lib/net.js
index 36fd0cc96f..1b2b348ee2 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -356,15 +356,13 @@ function initSocket (self) {
self.writable = false;
}
-function Socket (peerInfo) {
+function Socket (fd) {
process.EventEmitter.call(this);
- if (peerInfo) {
+ if (fd) {
initSocket(this);
- this.fd = peerInfo.fd;
- this.remoteAddress = peerInfo.remoteAddress;
- this.remotePort = peerInfo.remotePort;
+ this.fd = fd;
this.resume();
this.readable = true;
@@ -758,18 +756,20 @@ function Server (listener) {
self.watcher = new IOWatcher();
self.watcher.host = self;
- self.watcher.callback = function (readable, writeable) {
+ self.watcher.callback = function () {
while (self.fd) {
var peerInfo = accept(self.fd);
if (!peerInfo) return;
- var peer = new Socket(peerInfo);
- peer.type = self.type;
- peer.server = self;
- self.emit('connection', peer);
+ var s = new Socket(peerInfo.fd);
+ s.remoteAddress = peerInfo.remoteAddress;
+ s.remotePort = peerInfo.remotePort;
+ s.type = self.type;
+ s.server = self;
+ self.emit('connection', s);
// The 'connect' event probably should be removed for server-side
// sockets. It's redundent.
- peer.emit('connect');
- timeout.active(peer);
+ s.emit('connect');
+ timeout.active(s);
}
};
}