c - 套接字:是什么导致 read() 返回 EINVAL?

标签 c sockets io blocking nonblocking

一个套接字客户端程序与服务器建立连接, 使用(阻塞)read() 写入一些字节并等待响应。

但这失败了,错误为 EINVAL(“无效参数”)。 之前对 create()bind()connect() 套接字的调用已成功完成。

我的问题

  • 这里有什么问题吗?

平台是 Linux x64。

最佳答案

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.

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

关于c - 套接字:是什么导致 read() 返回 EINVAL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6018974/

相关文章:

c++ - 警告 : cast from pointer to integer of different size [-Wxpointer-to-int-cast]

c - ARMv5 上的 libsodium 段错误

c - 在我的 C 程序中遇到结构和数组问题

c - TCP 套接字超时或无数据可读取

java - 扫描仪在使用 next() 或 nextFoo() 后跳过 nextLine()?

io - 在 Julia 中追加或创建 HDF5 文件

c - 如何释放内存?

python - 当 QApplication 退出时,QT 引发段错误(核心已转储)

sockets - Docker如何在特定端口(8080)上建立与容器的TCP连接?

c - 套接字编程问题