mirror of
https://github.com/nodejs/node.git
synced 2025-08-17 22:58:52 +02:00
Remove 'connect' event from server side sockets
Sockets emitted by the 'connection' event are always connected, having them emit the 'connect' event makes no sense. It only confused people, as it's not clear if you have to listen to 'connect' or not. That try..catch block was also very scary. It would silently swallow exceptions in 'connect' listeners and destroy the socket. Makes no sense. Fixes #1047.
This commit is contained in:
parent
a72284e264
commit
f0a440d886
2 changed files with 1 additions and 12 deletions
|
@ -951,15 +951,6 @@ function Server(/* [ options, ] listener */) {
|
|||
|
||||
DTRACE_NET_SERVER_CONNECTION(s);
|
||||
self.emit('connection', s);
|
||||
|
||||
// The 'connect' event probably should be removed for server-side
|
||||
// sockets. It's redundant.
|
||||
try {
|
||||
s.emit('connect');
|
||||
} catch (e) {
|
||||
s.destroy(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -30,9 +30,7 @@ var client_recv_count = 0;
|
|||
var disconnect_count = 0;
|
||||
|
||||
var server = net.createServer(function(socket) {
|
||||
socket.addListener('connect', function() {
|
||||
socket.write('hello\r\n');
|
||||
});
|
||||
|
||||
socket.addListener('end', function() {
|
||||
socket.end();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue