【问题标题】:Using standard read() and write() calls on a socket in C [duplicate]在 C 中的套接字上使用标准的 read() 和 write() 调用 [重复]
【发布时间】:2015-11-29 19:31:41
【问题描述】:

在套接字 fd 上使用 read()write() 而不是 send()recv() 有什么不好的吗?我考虑在我的程序中使用它,因为 read()write()send()recv() 简单得多。

【问题讨论】:

  • 没有一个额外的参数设置为零会使它们“简单得多”?!

标签: c linux sockets unix


【解决方案1】:

不,这并没有什么问题,man 7 socket 明确告诉您可以对它们使用标准调用。

虽然 send 和 recv 函数并不难使用,但您可以将 0 作为 flags 参数传递,以获得与普通读写相同的行为。

【讨论】:

    猜你喜欢
    • 2015-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-28
    • 1970-01-01
    • 2016-05-20
    • 2010-10-17
    • 1970-01-01
    相关资源
    最近更新 更多