> For the complete documentation index, see [llms.txt](https://socket.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi.md).

# 4 服务端-API(Server-API)

- [4.1 server](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server.md)
- [4.1.1 HTTP服务选项 new\_server\_httpserver\_options](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/new_server_httpserver_options.md)
- [4.1.2 服务器端口选项 new\_server\_port\_options](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/new_server_port_options.md)
- [4.1.3 服务器选项 new\_server\_options](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/new_server_options.md)
- [4.1.4 服务器sockets server\_sockets](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_sockets.md)
- [4.1.5 服务器serverClient值 server\_serverClient\_value](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_serverclient_value.md)
- [4.1.6 服务器路径值 server\_path\_value](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_path_value.md)
- [4.1.7 服务器适配器值 server\_adapter\_value](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_adapter_value.md)
- [4.1.8 服务器源值 server\_origins\_value](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_origins_value.md)
- [4.1.9 服务器源函数 server\_origins\_fn](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_origins_fn.md)
- [4.1.10 服务器附加HTTP服务选项 server\_attach\_httpServer\_options](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_attach_httpserver_options.md)
- [4.1.11 服务器附加端口选项 server\_attach\_port\_options](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_attach_port_options.md)
- [4.1.12 服务器监听HTTP服务选项 server\_listen\_httpServer\_options](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_listen_httpserver_options.md)
- [4.1.13 服务器监听端口选项 server\_listent\_port\_options](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_listent_port_options.md)
- [4.1.14 服务器绑定引擎 server\_bind\_engine](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_bind_engine.md)
- [4.1.15 服务器连接socket server\_onconnection\_socket](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_onconnection_socket.md)
- [4.1.16 服务器命名空间(nsp) server\_of\_nsp](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_of_nsp.md)
- [4.1.17 服务器关闭回调 server\_close\_callback](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_close_callback.md)
- [4.1.18 服务器引擎生成socket ID server\_engine\_generateid](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.1-server/server_engine_generateid.md)
- [4.2 命名空间(namespace)](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace.md)
- [4.2.1 命名空间 namespace](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/namespace.md)
- [4.2.2 命名空间名称 namespace\_name](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/namespace_name.md)
- [4.2.3 命名空间连接 namespace\_connected](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/namespace_connected.md)
- [4.2.4 命名空间适配器 namespace\_adapter](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/namespace_adapter.md)
- [4.2.5 命名空间到房间 namespace\_to\_room](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/namespace_to_room.md)
- [4.2.6 命名空间在房间 namespace\_in\_room](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/namespace_in_room.md)
- [4.2.7 命名空间发送事件参数 namespace\_emit\_eventname\_args](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/namespace_emit_eventname_args.md)
- [4.2.8 命名空间客户端回调 namespace\_clients\_callback](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/namespace_clients_callback.md)
- [4.2.9 命名空间中间件函数 namespace\_use\_fn](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/namespace_use_fn.md)
- [4.2.10 连接事件 event\_connect](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/event_connect.md)
- [4.2.11 事件连接 event\_connection](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/event_connection.md)
- [4.2.12 可见性标志位 flag\_volatile](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/flag_volatile.md)
- [4.2.13 二进制标志位 flag\_binary](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/flag_binary.md)
- [4.2.14 本地标记位 flag\_local](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.2-ming-ming-kong-jian-namespace/flag_local.md)
- [4.3 socket](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket.md)
- [4.3.1 socket\_id](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_id.md)
- [4.3.2 socket\_rooms](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_rooms.md)
- [4.3.3 socket\_client](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_client.md)
- [4.3.4 socket\_conn](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_conn.md)
- [4.3.5 socket\_request](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_request.md)
- [4.3.6 socket\_handshake](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_handshake.md)
- [4.3.7 socket\_use\_fn](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_use_fn.md)
- [4.3.8 socket\_send\_args\_ack](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_send_args_ack.md)
- [4.3.9 socket\_emit\_eventName\_args\_ack](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/4.3.9-socket_emit_eventname_args_ack.md)
- [4.3.10 socket\_on\_eventName\_callback](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/4.3.10-socket_on_eventname_callback.md)
- [4.3.11 socket\_once\_eventName\_listener](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/4.3.11-socket_once_eventname_listener.md)
- [4.3.12 socket\_removelistener\_eventName\_listener](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/4.3.12-socket_removelistener_eventname_listener.md)
- [4.3.13 socket\_removeAllListeners\_eventName](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_removealllisteners_eventname.md)
- [4.3.14 socket\_eventNames](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_eventnames.md)
- [4.3.15 socket\_join\_room\_callback](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_join_room_callback.md)
- [4.3.16 socket\_join\_rooms\_callback](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_join_rooms_callback.md)
- [4.3.17 socket\_leave\_room\_callback](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_leave_room_callback.md)
- [4.3.18 socket\_to\_room](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_to_room.md)
- [4.3.19 socket\_in\_room](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_in_room.md)
- [4.3.20 socket\_compress\_value](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_compress_value.md)
- [4.3.21 socket\_disconnect\_close](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/socket_disconnect_close.md)
- [4.3.22 flag\_broadcast](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/flag_broadcast.md)
- [4.3.23 flag\_volatile](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/flag_volatile.md)
- [4.3.24 flag\_binary](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/flag_binary.md)
- [4.3.25 event\_disconnect](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/event_disconnect.md)
- [4.3.26 event\_error](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/event_error.md)
- [4.3.27 event\_disconnecting](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.3-socket/event_disconnecting.md)
- [4.4 client](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.4-client.md)
- [4.4.1 client](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.4-client/client.md)
- [4.4.2 client\_conn](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.4-client/client_conn.md)
- [4.4.3 client\_request](https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi/4.4-client/client_request.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://socket.gitbook.io/docs/4-fu-wu-duan-apiserverapi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
