[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / lib / misc / cbits / recvFrom.c
1 /* -----------------------------------------------------------------------------
2  * $Id: recvFrom.c,v 1.3 1998/12/02 13:26:46 simonm Exp $
3  *
4  * recvFrom 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 recvFrom__(StgInt fd, StgAddr buf, StgInt nbytes, StgAddr from)
16 {
17   StgInt count;
18   int sz;
19   int flags = 0;
20
21   sz = sizeof(struct sockaddr_in);
22
23   while ( (count = recvfrom((int)fd, (void*)buf, (int)nbytes, flags, (struct sockaddr*)from, &sz)) < 0) {
24       if (errno != EINTR) {
25           cvtErrno();
26           stdErrno();
27           return -1;
28       }
29   }
30   return count;
31 }