ReactOS 0.4.15-dev-7887-g64a59a1
SSendtoByName.c File Reference
#include "syshdrs.h"
Include dependency graph for SSendtoByName.c:

Go to the source code of this file.

Functions

int SSendtoByName (int sfd, const char *const buf, size_t size, int fl, const char *const toAddrStr, int tlen)
 
int SendtoByName (int sfd, const char *const buf, size_t size, const char *const toAddrStr)
 

Function Documentation

◆ SendtoByName()

int SendtoByName ( int  sfd,
const char *const  buf,
size_t  size,
const char *const  toAddrStr 
)

Definition at line 133 of file SSendtoByName.c.

134{
135 int result;
136 struct sockaddr_in toAddr;
137
138 if ((result = AddrStrToAddr(toAddrStr, &toAddr, -1)) < 0) {
139 return (result);
140 }
141
142 do {
143 result = sendto(sfd, buf, size, 0,
144 (struct sockaddr *) &toAddr,
145 (int) sizeof(struct sockaddr_in));
146 } while ((result < 0) && (errno == EINTR));
147
148 return (result);
149} /* SendtoByName */
#define EINTR
Definition: acclib.h:80
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
Definition: send.c:82
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint64EXT * result
Definition: glext.h:11304
int AddrStrToAddr(const char *const, struct sockaddr_in *const, const int)
Definition: StrAddr.c:54
#define errno
Definition: errno.h:18

◆ SSendtoByName()

int SSendtoByName ( int  sfd,
const char *const  buf,
size_t  size,
int  fl,
const char *const  toAddrStr,
int  tlen 
)

Definition at line 73 of file SSendtoByName.c.

74{
75 int nwrote, tleft;
76 time_t done, now;
77 fd_set ss;
78 struct timeval tv;
79 int result;
80 struct sockaddr_in toAddr;
81
82 if ((result = AddrStrToAddr(toAddrStr, &toAddr, -1)) < 0) {
83 return (result);
84 }
85
86 time(&now);
87 done = now + tlen;
88 nwrote = 0;
89 forever {
90 forever {
91 if (now >= done) {
93 return (kTimeoutErr);
94 }
95 tleft = (int) (done - now);
96 errno = 0;
97 FD_ZERO(&ss);
98 FD_SET(sfd, &ss);
99 tv.tv_sec = tleft;
100 tv.tv_usec = 0;
102 if (result == 1) {
103 /* ready */
104 break;
105 } else if (result == 0) {
106 /* timeout */
108 return (kTimeoutErr);
109 } else if (errno != EINTR) {
110 return (-1);
111 }
112 time(&now);
113 }
114
115 nwrote = sendto(sfd, buf, size, fl,
116 (struct sockaddr *) &toAddr,
117 (int) sizeof(struct sockaddr_in));
118
119 if (nwrote >= 0)
120 break;
121 if (errno != EINTR)
122 break; /* Fatal error. */
123 }
124
125 return (nwrote);
126} /* SSendto */
#define NULL
Definition: types.h:112
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
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
#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 kTimeoutErr
Definition: sio.h:58
#define forever
Definition: ncftp.h:73
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