release
[hcoop/zz_old/debian/djbdns.git] / socket_accept.c
CommitLineData
dc0d77d7
CE
1#include <sys/types.h>
2#include <sys/param.h>
3#include <sys/socket.h>
4#include <netinet/in.h>
5#include "byte.h"
6#include "socket.h"
7
8int socket_accept4(int s,char ip[4],uint16 *port)
9{
10 struct sockaddr_in sa;
11 int dummy = sizeof sa;
12 int fd;
13
14 fd = accept(s,(struct sockaddr *) &sa,&dummy);
15 if (fd == -1) return -1;
16
17 byte_copy(ip,4,(char *) &sa.sin_addr);
18 uint16_unpack_big((char *) &sa.sin_port,port);
19
20 return fd;
21}