[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / lib / misc / cbits / sendTo.c
1 /* -----------------------------------------------------------------------------
2  * $Id: sendTo.c,v 1.3 1998/12/02 13:26:46 simonm Exp $
3  *
4  * sendTo run-time support
5  *
6  * (c) The GHC Team 1998
7  * -------------------------------------------------------------------------- */
8
9 #define NON_POSIX_SOURCE
10 #include "Rts.h"
11 #include "ghcSockets.h"
12 #include "stgio.h"
13
14 StgInt
15 sendTo__(StgInt fd, StgAddr buf, StgInt nbytes, StgAddr to, StgInt sz)
16 {
17   StgInt count;
18   int flags = 0;
19
20   while ( (count = sendto((int)fd, (void*)buf, (int)nbytes, flags, (struct sockaddr*)to, sz)) < 0) {
21       if (errno != EINTR) {
22           cvtErrno();
23           stdErrno();
24           return -1;
25       }
26   }
27   return count;
28 }