ReactOS 0.4.15-dev-7681-g776c3a3
SRecvfrom.c File Reference
#include "syshdrs.h"
Include dependency graph for SRecvfrom.c:

Go to the source code of this file.

Functions

int SRecvfrom (int sfd, char *const buf, size_t size, int fl, struct sockaddr_in *const fromAddr, int tlen)
 

Function Documentation

◆ SRecvfrom()

int SRecvfrom ( int  sfd,
char *const  buf,
size_t  size,
int  fl,
struct sockaddr_in *const  fromAddr,
int  tlen 
)

Definition at line 69 of file SRecvfrom.c.

70{
71 int nread, tleft;
72 fd_set ss;
73 struct timeval tv;
74 int result;
75 time_t done, now;
76 int alen;
77
78 time(&now);
79 done = now + tlen;
80 tleft = (int) (done - now);
81 nread = 0;
82 forever {
83 alen = sizeof(struct sockaddr_in);
84
85 forever {
86 errno = 0;
87 FD_ZERO(&ss);
88 FD_SET(sfd, &ss);
89 tv.tv_sec = tleft;
90 tv.tv_usec = 0;
92 if (result == 1) {
93 /* ready */
94 break;
95 } else if (result == 0) {
96 /* timeout */
99 return (kTimeoutErr);
100 } else if (errno != EINTR) {
101 return (-1);
102 }
103 }
104
105 nread = recvfrom(sfd, buf, size, fl,
106 (struct sockaddr *) fromAddr, &alen);
107
108 if (nread >= 0)
109 break;
110 if (errno != EINTR)
111 break; /* Fatal error. */
112 errno = 0;
113 time(&now);
114 tleft = (int) (done - now);
115 if (tleft < 1) {
116 nread = kTimeoutErr;
119 break;
120 }
121 }
122
123 return (nread);
124} /* SRecvfrom */
#define EINTR
Definition: acclib.h:80
#define NULL
Definition: types.h:112
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
Definition: recv.c:87
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
#define ETIMEDOUT
Definition: errno.h:121
__kernel_time_t time_t
Definition: linux.h:252
time_t now
Definition: finger.c:65
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint64EXT * result
Definition: glext.h:11304
#define ss
Definition: i386-dis.c:441
#define SELECT_TYPE_ARG234
Definition: wincfg.h:4
#define SELECT_TYPE_ARG5
Definition: wincfg.h:7
__u16 time
Definition: mkdosfs.c:8
#define SETWSATIMEOUTERR
Definition: sio.h:120
#define kTimeoutErr
Definition: sio.h:58
#define forever
Definition: ncftp.h:73
#define errno
Definition: errno.h:18
Definition: winsock.h:66
_In_ FLONG fl
Definition: winddi.h:1279
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89