[comp.unix.questions] Flushing sockets

jseidman@jarthur.Claremont.EDU (James Seidman) (02/14/90)

I'm writing some socket code, and I need to make sure that a final message
goes out before I disconnect.  If I close the socket soon after writing
the message, it often doesn't make it out.  Putting in a sleep(1) between
the write and the close fixes the problem, but since this one program
serves several sockets, I don't want to do that.  Is there an equivalent
to fflush which works on sockets?  My system has a man page for a routine
called flush, but it appears to be only for assembly language routines.
-- 
-------------------------------------------------------------------------------
Jim Seidman, Harvey Mudd College, Claremont, CA 91711.  (714) 621-8000 x2026
DISCLAIMER: I don't even know if these are opinions, let alone those of
            anyone other than me.

ian@hpopd.HP.COM (Ian Watson) (03/07/90)

I haven't actually used it, but from my man pages, it looks like you can call

setsockopt ( sock, SOL_SOCKET, SO_LINGER, optval, optlen);

with optval a pointer to 'struct linger' (defined in <sys/socket.h>), and
optlen set to its length.  This is on SCO V.3.2.

If this helps, maybe you can return a favour by casting an eye over my
question in this group "HELP!! Sockets ..." (ian@hpopd.HP.COM)

Cheers,
Ian Watson