nodejs socket.io callbacks logic

io.sockets.on('connection', function(socket){  
    socket.on('customevent', function(){...})   
...})

io.sockets.on simplified logic: each socket will respond to an event ('connection' by default); socket.on simplified logic: each socket will respond to an event only if connection is established (only when 'connection' event is received);

So, what is the logic here? Is io.sockets.on function used only for establishing connection like a simple callback? I see that both functions stand for 'each socket responds' and there is no need in socket.on because io.sockets.on will respond to all events as well as socket.on's given socket.

Could someone explain me?

It's possible for different socket connections to handle different events differently, depending on their nature. io.sockets.on(...) specifies common behavior for all socket connections (i.e. behavior that doesn't depend on the identity of the connection); socket.on(...) (where socket represents a particular connection) specifies behavior specific to that connection.