ReactOS  0.4.14-dev-49-gfb4591c
SAcceptS.c
Go to the documentation of this file.
1 #include "syshdrs.h"
2 
3 int
4 SAcceptS(int sfd, struct sockaddr_in *const addr, int tlen)
5 {
6  int result;
7  fd_set ss;
8  struct timeval tv;
9  size_t size;
10 
11  if (tlen <= 0) {
12  errno = 0;
13  for (;;) {
14  size = sizeof(struct sockaddr_in);
15  result = accept(sfd, (struct sockaddr *) addr, (int *) &size);
16  if ((result >= 0) || (errno != EINTR))
17  return (result);
18  }
19  }
20 
21  forever {
22  errno = 0;
23  FD_ZERO(&ss);
24  FD_SET(sfd, &ss);
25  tv.tv_sec = tlen;
26  tv.tv_usec = 0;
28  if (result == 1) {
29  /* ready */
30  break;
31  } else if (result == 0) {
32  /* timeout */
33  errno = ETIMEDOUT;
35  return (kTimeoutErr);
36  } else if (errno != EINTR) {
37  return (-1);
38  }
39  }
40 
41  do {
42  size = sizeof(struct sockaddr_in);
43  result = accept(sfd, (struct sockaddr *) addr, (int *) &size);
44  } while ((result < 0) && (errno == EINTR));
45 
46  return (result);
47 } /* SAcceptS */
Definition: winsock.h:66
#define SELECT_TYPE_ARG234
Definition: wincfg.h:4
int SAcceptS(int sfd, struct sockaddr_in *const addr, int tlen)
Definition: SAcceptS.c:4
#define EINTR
Definition: acclib.h:80
unsigned long tv_sec
Definition: linux.h:1738
int errno
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
smooth NULL
Definition: ftsmooth.c:416
unsigned long tv_usec
Definition: linux.h:1739
#define kTimeoutErr
Definition: sio.h:58
GLsizeiptr size
Definition: glext.h:5919
GLenum const GLvoid * addr
Definition: glext.h:9621
#define SELECT_TYPE_ARG5
Definition: wincfg.h:7
#define forever
Definition: ncftp.h:73
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
#define SETWSATIMEOUTERR
Definition: sio.h:120
#define ETIMEDOUT
Definition: errno.h:121
#define ss
Definition: i386-dis.c:432
GLuint64EXT * result
Definition: glext.h:11304