> 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>` (命名空间作为有效负载的一部分发送)
