home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source$
- * $Date$
- * $Revision$
- * $State$
- * $Author$
- *
- * $Log$
- * (c) Copyright 1995 Sergio Monesi
- ***************************************************************************/
-
- static const char rcs_id[] = "$Id$";
-
- #include <errno.h>
-
- #include <sys/unix.h>
- #include <sys/socket.h>
- #include <sys/dev.h>
- #include <fcntl.h>
-
- int
- socket (int af, int type, int protocol)
- {
- register struct file *f;
- int fd;
- int sd;
-
- if ((sd = _socket (af, type, protocol)) < 0)
- return (-1);
-
- if ((fd = __fdalloc ()) < 0)
- return (-1);
-
- /* printf("U! socket: sd=%d fd=%d\n",sd,fd); */
-
- f = __u->file + fd;
- f->oflag = O_RDWR | O_BINARY;
- f->r[0] = sd;
- f->r[1] = af;
- f->r[2] = type;
- f->r[3] = protocol;
-
- f->dev = makedev (DEV_SOCKET, sd);
-
- f->dup = f;
- f->pid = __u->pid;
-
- return (fd);
- }
-