
#include "V.h"
#include "sys_socket.h"
/*
* This wrapper for the accept system call also notes the address/port
* returned, and caches it in the openfile list entry.
*/
d_accept(s,a,l)
	int  s;
	SKAD*a;
	SKln*l;
{	int  e,v;
	SKAD ad;
	SKin*ap;
	V5 "accept(%d,%08X,%08X=%d)",s,a,l,*l D;
	if (!a) a = &ad;
	ap = (SKin*)a;
	errno = 0;
	v = accept(s,a,(SKln*)l);
	e = errno;
	V6 "accept(%d,%08X,%08X=%d)=%d [Err %d=%s=%s]",s,a,l,*l,v,Errinfo D;
	if (v >= 0) {
		File *fp;
		if ((a->sa_family == AF_INET) && (fp = d_newfile(File_LOCAL,v,"accept-sock","open"))) {
			fp->addr = ap->sin_addr.s_addr;
			fp->port = ntohs(ap->sin_port);
		}
	}
	errno = e;
	return v;
}
