As far as I know, the Express app object does not know the server object. The way things work in Express, the app object is given to the server object, not the other way around. In fact a single app object can even be used with more than one server (sometimes done for an http and https server).
You can get access to the server object from within a request handler with req.connection.server, but that comes from the server as part of the context with a request, that’s not something the app object itself knows.
So, if you want access to the server object for use with socket.io at initialization time, you will have to capture the server object into a variable where it is created.
The code you show in your question does not create or start a server. The usual two ways to start a server for use with Express are this:
const express = require('express');
const app = express();
// Express creates a server for you and starts it
const server = app.listen(80);
Or, you create the server yourself and pass express to it as the handler:
const express = require('express');
const app = express();
// you explicitly create the http server
const server = require('http').createServer(app);
server.listen(80);
In each of these cases, you end up with the server object in a variable and can then use that with socket.io.
You can get access to the server from inside an Express route handler within the processing of a request from either the req or res object that are passed to a request handler.
res.connection.server
req.connection.server