ReactOS  0.4.14-dev-57-g333b8f1
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 */
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define EINTR
Definition: acclib.h:80
int errno
int AddrStrToAddr(const char *const, struct sockaddr_in *const, const int)
Definition: StrAddr.c:54
GLsizeiptr size
Definition: glext.h:5919
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
GLuint64EXT * result
Definition: glext.h:11304

◆ 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) {
92  errno = ETIMEDOUT;
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 */
107  errno = ETIMEDOUT;
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 */
Definition: winsock.h:66
#define SELECT_TYPE_ARG234
Definition: wincfg.h:4
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define EINTR
Definition: acclib.h:80
int errno
__u16 time
Definition: mkdosfs.c:366
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
int AddrStrToAddr(const char *const, struct sockaddr_in *const, const int)
Definition: StrAddr.c:54
_In_ FLONG fl
Definition: winddi.h:1279
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
time_t now
Definition: finger.c:65
smooth NULL
Definition: ftsmooth.c:416
#define kTimeoutErr
Definition: sio.h:58
GLsizeiptr size
Definition: glext.h:5919
#define SELECT_TYPE_ARG5
Definition: wincfg.h:7
#define forever
Definition: ncftp.h:73
__kernel_time_t time_t
Definition: linux.h:252
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
#define ETIMEDOUT
Definition: errno.h:121
#define ss
Definition: i386-dis.c:432
GLuint64EXT * result
Definition: glext.h:11304
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31