When setting and getting session data with Socket.IO, what are passed functions for?

In the following code snippet taken from the Socket.IO website,

socket.set('nickname', name, function () {
    socket.emit('ready');
});

when setting client data, what's the passed function used for? Is it used simply to fire the function once the data is set? If so, what's the difference with:

socket.set('nickname', name);
socket.emit('ready');

Also what is err used for in the following:

socket.get('nickname', function (err, name) {
    console.log('Chat message by ', name);
});

when setting client data, what's the passed function used for

That's an async callback, which means it's a function that will be called after the set operation was completed

If so, what's the difference with...

It's a big difference. socket.set is non-blocking, which means the method will be called but the process will continue with the following code, without waiting for it to finish. This means the socket.emit will be called before the set was completed.

Also what is 'err' used for in the following:

err can be a connection error or anything that went wrong during the get method