关于php的socket_read函数的问题

WBOY
Release: 2016-06-06 20:43:54
Original
1114 people have browsed it

假设read一个socket,参数为1000,socket_read(socketfd, buf, 1000),对方假设发送了400字节数据,然后现在socket接收缓冲区里只收到了400字节数据,问这个时候,read是否会返回400字节呢,还是继续阻塞等到剩余的600字节?

回复内容:

假设read一个socket,参数为1000,socket_read(socketfd, buf, 1000),对方假设发送了400字节数据,然后现在socket接收缓冲区里只收到了400字节数据,问这个时候,read是否会返回400字节呢,还是继续阻塞等到剩余的600字节?

收到数据后会立刻返回,不会再阻塞等待其余600字节

我说一个题外话,之前用C的一个函数测试着玩, 是一个写入的动作,其实真实的内容比另一个参数小的多,后来用VIM打开文件发现全是@@@填充的(这里的@应该是什么字符什么的吧,表示不懂)

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!