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.
Share
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:At the end of your session, calling
shutdown(sock, SHUT_WR)to close out writes on the socket.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.