e9e719b7658335a6f7df76e071d7f7b9d5713215
[ghc-hetmet.git] / ghc / lib / misc / cbits / sendTo.c
1 #if 0
2 %
3 % (c) The GRASP/AQUA Project, Glasgow University, 1998
4 %
5 \subsection[sendTo.c]{sendTo run-time support}
6
7 \begin{code}
8 #endif
9
10 #define NON_POSIX_SOURCE
11 #include "rtsdefs.h"
12 #include "ghcSockets.h"
13
14 StgInt
15 sendTo__(fd, buf, nbytes, to, sz)
16 StgInt fd;
17 StgAddr buf;
18 StgInt nbytes;
19 StgAddr to;
20 StgInt  sz;
21 {
22   StgInt count;
23   int flags = 0;
24
25   while ( (count = sendto((int)fd, (void*)buf, (int)nbytes, flags, (struct sockaddr*)to, sz)) < 0) {
26       if (errno != EINTR) {
27           cvtErrno();
28           stdErrno();
29           return -1;
30       }
31   }
32   return count;
33 }