Files
Socket/vendor/swoole/ide-helper/config/chinese/server/method/send.php
T
2026-01-28 23:48:20 +08:00

27 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
return array(
//注释
'comment' => '
* 向客户端发送数据
*
* * $data,发送的数据。TCP协议最大不得超过2M,UDP协议不得超过64K
* * 发送成功会返回true,如果连接已被关闭或发送失败会返回false
*
* TCP服务器
* -------------------------------------------------------------------------
* * send操作具有原子性,多个进程同时调用send向同一个连接发送数据,不会发生数据混杂
* * 如果要发送超过2M的数据,可以将数据写入临时文件,然后通过sendfile接口进行发送
*
* swoole-1.6以上版本不需要$from_id
*
* UDP服务器
* ------------------------------------------------------------------------
* * send操作会直接在worker进程内发送数据包,不会再经过主进程转发
* * 使用fd保存客户端IP,from_id保存from_fd和port
* * 如果在onReceive后立即向客户端发送数据,可以不传$reactor_id
* * 如果向其他UDP客户端发送数据,必须要传入$reactor_id
* * 在外网服务中发送超过64K的数据会分成多个传输单元进行发送,如果其中一个单元丢包,会导致整个包被丢弃。所以外网服务,建议发送1.5K以下的数据包
*',
//返回值
'return' => 'bool'
);