插座:是什么原因造成阅读()返回EINVAL? [英] Sockets: What is causing read() to return EINVAL?
问题描述
一个套接字客户端程序建立与服务器的连接,
写一些字节,并等待使用响应(阻塞)阅读()
。
A socket client program establishes a connection with the server,
writes some bytes and waits for response using the (blocking) read()
.
但这种失败,出现错误 EINVAL
(无效参数)。
previous调用创建()
,绑定()
和连接()
插座已成功进行。
But this fails with the error EINVAL
("Invalid argument").
Previous calls to create()
, bind()
and connect()
the socket have been made successfully.
我的提问
- 什么是错在这里?
平台是Linux的x64的。
Platform is Linux x64.
推荐答案
问题是,我通过一个大小为1字节到阅读()
的功能。
看来,这是不支持结果
的(为什么?什么是最小尺寸是多少?它必须是2的倍数/平台的位数?)。的
The problem was that I passed a size of 1 byte to the read()
function.
It seems that this is not supported
(why? what is the minimum size? must it be a multiple of 2/the bitness of the platform?).
现在我传递8和它的作品。
谢谢大家的意见。
Now I am passing 8 and it works. Thank you all for your comments.
这篇关于插座:是什么原因造成阅读()返回EINVAL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!