有没有一种方法来刷新一个POSIX插座? [英] Is there a way to flush a POSIX socket?

查看:143
本文介绍了有没有一种方法来刷新一个POSIX插座?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个标准要求所有的方式,通过对端还是这方面的需求实现为用户级协议的一部分冲洗POSIX接口的发射端?我看了看周围的常规头,但无法找到任何东西。

Is there a standard call for flushing the transmit side of a POSIX socket all the way through to the remote end or does this need to be implemented as part of the user level protocol? I looked around the usual headers but couldn't find anything.

推荐答案

有关Unix域套接字,您可以使用 fflush(),但我可能会想你意思是网络套接字。是不是真的有这些冲洗的概念。最近的事情是:

For Unix-domain sockets, you can use fflush(), but I'm thinking you probably mean network sockets. There isn't really a concept of flushing those. The closest things are:

1)在你的会话最后,调用关机(袜子,SHUT_WR)收出写入套接字。

1) At the end of your session, calling shutdown(sock, SHUT_WR) to close out writes on the socket.

2)在TCP套接字,禁用Nagle算法与sockopt的 TCP_NODELAY ,这通常是一个可怕的想法,将无法可靠地做你想做的,即使它似乎照顾它的初步调查。

2) On TCP sockets, disabling the Nagle algorithm with sockopt TCP_NODELAY, which is generally a terrible idea that will not reliably do what you want, even if it seems to take care of it on initial investigation.

这很可能是处理一切问题在用户协议级别要求一个'刷新'将是正确的事情。

It's very likely that handling whatever issue is calling for a 'flush' at the user protocol level is going to be the right thing.

这篇关于有没有一种方法来刷新一个POSIX插座?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆