Sockets: What is causing read() to return EINVAL?

故事扮演 提交于 2019-12-08 23:13:29

fd is attached to an object which is unsuitable for reading; or the file was opened with the O_DIRECT flag, and either the address specified in buf, the value specified in count, or the current file offset is not suitably aligned.

See http://www.kernel.org/doc/man-pages/online/pages/man2/read.2.html

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?).

Now I am passing 8 and it works. Thank you all for your comments.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!