# 4.1.17 服务器关闭回调 server\_close\_callback

* `callback`(Function)

关闭socket.io服务器。`callback(回调)`参数是可选的，将在关闭所有连接时调用。

```javascript
const Server= require('socket.io');
const PORT=3030;
const server= require('http').Server()

const io= Server(PORT);

io.close() //关闭当前的服务器

server.listen(PORT);// 释放端口

io=Server(server);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_close_callback.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
