I am using node.js connect framework to listen to upgrade event. I can use the socket in callback function to write back to client. But how can I use the socket outside callback function to write to same client. In my case there is only one client connected to server.
app.on('upgrade', function(req, socket) {
socket.write('hello');
});
function sendEvent()
{
// how to use socket here??
}
sendEvent();