> 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/2-wen-dang-docs/2.3-cong-0.9-qian-yi-ban-ben-migratingfrom0.9/shorcuts.md).

# 2.3.3 快捷方式

一般来说，常见事物有一些新的捷径。旧版本应该仍然有效，但是快捷方式很好。

## 向默认命名空间中的所有客户端广播

以前:

```javascript
io.sockets.emit('eventname',"eventdata");
```

现在：

```javascript
io.emit('eventname','eventdata')
```

整洁。

请注意，在这两种情况下，这些消息都会到达连接到默认“/”命名空间的所有客户端，但不会到达其他命名空间中的客户端。

## 启动服务端

以前：

```javascript
const io = require('socket.io');
const socket=io.listen(80,{/*选项*/});
```

现在：

```javascript
const io=require('socket.io');
const socket=io({/*选项*/})
`
```
