> 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/3-ke-hu-duan-apiclientapi/3.1-io/initialization_examples_with_custom_path.md).

# 3.1.4 初始化示例-自定义路径

```javascript
const socket= io('http://localhost',{
    path:"/myownpath"
})

// 服务端
const io =require('socket.io')({
    path:"/myownpath"
})
```

请求的URLS会像:`localhost/myownpath/?EIO=3&transport=polling&sid=<id>`

```javascript
const socket= io('http://localhost/admin',{
    path:"/mypath"
})
```

在这里，socket通过自定义路径`mypath`连接到`admin`命名空间。

请求的URLS会像:`localhost/mypath/?EIO=3&transport=polling&sid=<id>` (命名空间作为有效负载的一部分发送)


---

# 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:

```
GET https://socket.gitbook.io/docs/3-ke-hu-duan-apiclientapi/3.1-io/initialization_examples_with_custom_path.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.
