
#include "V_s_lc.h"
#include "sys_socket.h"
/*
*/
 global int dbn_send = 0;	/* Call counter */
extern Flag Vchknull;		/* If true, check for nulls */
extern int  Vmaxnull;		/* If true, max length string of nulls */
extern int  Vlennull;		/* Longest string of nulls so far */

d_send(s,b,n,f)
	int   s;	/* Socket file handle */
	char *b;	/* Pointer to data */
	Sizt  n; 	/* Number of bytes */
	int   f;	/* Flags: MSG_OOB | MSG_DONTROUTE */
{	int   r;
	int   e,i;
	File *fp;
	if (fp = d_openfile(f))
		fp->writes++;
	P6s "%s\tSend %d bytes (write %d).",Vtime(),n,(fp?fp->writes:0) D;
	if (b && n) H7(b,n,"Message");
	if (Vchknull)
		if (i = Vcntnulls(b,n))
			V3 "### String of %d nulls written to sock %d.",i,s D;

	errno = 0;

	r = send(s,b,n,f);

	e = errno;
	++dbn_send;
	V6s "send(%d,%08lX,%d,%d)=%d (%d writes) [Err %d=%s=%s]"
		,s,b,n,f,r,(fp?fp->writes:0),Errlist D;
	errno = e;
	return r;
}
